after a day of alot of questionmarks i have to ask my question another way to find a solution.
i have a switch clause that works only up to the first case. the second case will not be executed and i don't know why this doesn't work.
here is the code:
if($query->num_rows === 1){
$row = $query->fetch_object();
$Status = $row->Status;
if(isset($_POST['submit'])){
$x1 = $_POST['x1'];
$x2 = $_POST['x2'];
...
$x11 = $_POST['x11'];
$x10Check = $db->query("SELECT * FROM tableB WHERE x10='".$x10."'");
$x11Check = $db->query("SELECT * FROM tableB WHERE x10='".$x10."' AND x11='".$x11."'");
if(empty($x1)||...||empty($x10)||empty($x11)){
if(empty($x1) && $Status == "S0"){
$errors[]="text";
}
if(empty($x4) && ($Status == "S0" || $Status == "S2")){
$errors[]="text";
}
...
if(empty($x11) && ($Status == "S0" || $Status == "S2")){
$errors[]="text";
}
}elseif(strlen($x10)< 5){
$errors[]="no x10";
}elseif(strlen($x10)> 5){
$errors[]="no x10";
}elseif(ctype_digit($x10) === false){
$errors[]="no x10";
}elseif($x10Check->num_rows === 0){
$errors[]="no x10";
}elseif($x11Check->num_rows === 0){
$errors[]="wrong";
}elseif($Status == "S1"){
$errors[]="no changings possible at the moment";
}else{
$x2 = strip_tags($x2);
$x2 = stripslashes($x2);
$x2 = trim($x2);
$x2 = $db->real_escape_string($x2);
...
$x11 = strip_tags($x11);
$x11 = stripslashes($x11);
$x11 = trim($x11);
$x11 = $db->real_escape_string($x11);
if($query->num_rows===1){
switch($Status){
case 'S0':
$update = $db->query("UPDATE table SET x1='".$x1."', ..., x11='".$x11."' WHERE id='".$id."'");
$msg ="text";
$updateStatus = $db->query("UPDATE table SET Status='S1' WHERE id='$id'");
break;
case 'S2':
$update2 = $db->query("UPDATE table SET x4='".$x4."', ..., x11='".$x11."' WHERE id='".$id."'");
$msg ="text";
$updateStatus2 = $db->query("UPDATE table SET Status='S1' WHERE id='$id'");
break;
default:
$errors[]="text error.";
break;
}
}
is there anybody who would be that friendly and could help. i would really appreciate. thanks.
the problem is that i have a form where a user can edit his profile. after registration the user will get automatically a status s0 for an unchecked registration. while the user has s0-status he has not full access to all features. the user can send more information through a form that first of all have to be checked. after he will submit information the status automatically changes from s0 to s1 which means, that he can't make any changes as long as his information have not been checked. after checking progress the user gets status s2. with that status he has full access and can edit some of his data again through a minimized form. after he has submit the new data he gets automatically back to s1 because all changes have to be checked. here's the main problem. the switch clause is only working correctly up to case1. all changes and errormessages work well. only when the user has s2-status and the form is minimized to just a few fields that the user can change, the changes won't be send and there will be no errormessages shown also.
Are you missing some closing curly braces? It's kind of confusing the way your sample code is laid out.