I have two PHP files.
The first (main_form.php) contains the HTML form and displays the errors if the form is incorrect. The errors are obtained for the second file.
The second file called validate.php has the following code to display errors:
foreach ($error as $errorKeys) {
$_SESSION['errors'] = $errorKeys;
echo $_SESSION['errors'];
}
header('Location: ../main_form.php');
If the header('Location: ../main_form.php'); is left out the errors display correctly.
The first file (main_form.php) has the following code to get the errors (if any) from validate.php:
echo '<ul>';
foreach ($_SESSION['errors'] as $errorKeys) {
//$errorKeys = $_SESSION['errors'];
echo $errorKeys;
}
echo '<ul>';
I am getting the following error in the error_log : PHP Warning: Invalid argument supplied for foreach()
The errors are in the form of arrays e.g. $error['business_website'] = Address is incorrect.
How can i parse the errors from validate.php to main_form.php please?