Hey all. I have a processForm function and a displayForm function. If there are missing form fields the processForm function returns an array of missing fields. This is all fine and dandy until I try to include this array into the displayForm function. Here's the problem:
If I don't do this:
displayForm($missingFields=array());
then my validateField function throws a warning that it is expecting the parameter to be an array. However, this overwrites the array returned by the processForm function.
I hope I'm clear. Thanks for any help.
Full Code:
if(isset($_POST['action']) && $_POST['action'] = "login")
{
$messages = processForm();
}
processForm()
if($errorMessages)
{
return array("errors" => $errorMessages, "missing" => $missingFields);
}
else
{
$_SESSION['user'] = $user;
header("Location: index.php");
}
form.php
(!isLoggedIn())? displayForm($messages['errors']=array(),$messages['missing']=array()) : null;
These are the sections of the code I'm having trouble with.
Thanks again.