I'm trying to display very specifc error messages if a user forgets a field in a form.... First, I detect what they have missed, like so:
if (!$ph1) { //if they forget areacode
$fault = 1;
$xfault = 1;
} if(!$ph2) { //or mid3
$fault = $fault+2;
$xfault = 1;
} if(!$ph3) { //or tail4
$fault = $fault+5;
$xfault = 1;
}
Then, I try to display error messages based on the value of $fault ($xfault is for something else)... For instance,
if($fault = 3) //if fault is 3, then first 3, and mid3 must be missing... (0+1=1,+2=3)
echo "Your phone number is missing the area code and first three digits! These are required to continue....";
} elseif ($fault = 1) {
echo "Your phone number is missing the area code! This is required to continue...";
}
and so on and so forth. However, regardless of how many fields I fill in, I always get the error message for the case when $fault = 1.... Which makes me think that I'm adding to the variables incorrectly or something. Does anyone see my caveat?