Hi, well i’m still working on my project and i encountered with another problem. I want to put orders into my databe, but first i want to check for errors. And the problem is that when i pres in my form “submit” button nothing is working it just doesnt react. :/// Maybe u can tell me where is the problem?
[php]
//process.php file
function procUzsakymas(){
global $session, $form;
$retval = $session->registerUzsakymas($_POST[‘uzsakymas’], $_POST[‘uzsakytas_kiekis’]);
if($retval == 0){
$_SESSION['reguz'] = $_POST['uzsakymas'];
$_SESSION['uzsuccess'] = true;
header("Location: ".$session->referrer);
}
/* Error found with form */
else if($retval == 1){
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ".$session->referrer);
}
/* attempt failed */
else if($retval == 2){
$_SESSION['reguz'] = $_POST['uzsakymas'];
$_SESSION['uzsuccess'] = false;
header("Location: ".$session->referrer);
}
}[/php]
[php]
//session.php file
function registerUzsakymas($subuz, $subuzskiekis){
global $database, $form;
/* checking for errors /
$field = “uzsakymas”;
if(!$subuz || strlen($subuz = trim($subuz)) == 0){
$form->setError($field, " field is empty");
}
else{
/* checking word lenght /
$subuz = stripslashes($subuz);
if(strlen($subuz) < 1){
$form->setError($field, " < 1 symbol");
}
else if(strlen($subuz) > 50){
$form->setError($field, “* to many symbols”);
}
/* Check if its not alphanumeric /
else if(!eregi("^([0-9a-z])+$", $subuz)){
$form->setError($field, " wrong symbol");
}
/* checking for the same name /
// else if(!$database->pavadinimasNeegzistuoja($subuz)){
// $form->setError($field, " that name you have entered doesnt exist");
// }
}
/* checking uzsakytas_kiekis errors */
$field = "uzsakytas_kiekis";
if(!$subuzskiekis){
$form->setError($field, "* field is empty");
}
else{
/* checking lenght */
$subuzskiekis = stripslashes($subuzskiekis);
if(strlen($subuzskiekis) < 1){
$form->setError($field, "* < 1 symbol");
}
/* checking for right symbol */
else if(!eregi("^([0-9])+$", $subuzskiekis)){
$form->setError($field, "* frong symbol");
}
}
/* nuber of errors */
if($form->num_errors > 0){
return 1; //Errors with form
}
/* if there is no errors it goes to database */
else{
if($database->addNewUzsakymas($subuz, $subuzskiekis)){
return 0; //added successfully
}else{
return 2; //failed to add
}
}
}
[/php]