i set up the $errors variable, and test each field if they have errors or not
- Code: Select all
$errors;
$required_fields = array('username' , 'password', 'email');
foreach($required_fields as $field)
{
if(empty($_POST[$field]))
{
$errors[] = "Please fill {$_POST[$field]}";
}
}
then i want to:
Add code to the handling of the $errors variable on the page that uses a foreach loop if $errors is an array, or just prints the value of $errors otherwise.
what im thinking is using is_array() function, to test $errors :
- Code: Select all
if( is_array($errors) )
then i tried to use var_dump() to test $errors (even if there is only 1 error) unfortunately its still an array.
i cant figure it out..

