Hi folks:
I have an array of form values, and all I want to do is loop thru the array of values and check for empty fields, if one exists print it's name:
//Someone wants to register
if(isset($send)) {
//Create an array of form contents
$formContents = array(Name=>'$Name',Address=>'$Address',Age=>'$Age',Status=>'$Status',Email=>'$Email',Course=>'$Course',HomePhone=>'$HomePhone',MobilePhone=>'$MobilePhone',TeamSelection=>'$team_list',Username=>'$Username',Password=>'$Password',Password2=>'$Password2');
/
While loop to get array key names to display upon error (Blank field)
/
while(list($key, $value) = each($formContents)) {
/
for loop to check each array element for empty element (devoide of data
/
for ($t=0; $t < count($formContents) ;$t++) {
$current = current($formContents);
if (empty($current)) {
$error = "The \"$key\" field was left empty!<br>";
}
}
echo $error;
}
}
This refuses to work, (and has done all damn day!) It simply returns the last form field from my form regardless of it being empty or not! What am I doing wrong??
Cheers.
Russ