I have a functioning procedure which checks if a form has fields completed - if not it warns the user and redirects them to the form. Trouble is im getting an undefined index error but im not entirely sure why:
here is the form page
////form output echoed here
//then at bottom of form
<?php
//if validate errors exists, list them out
if(count($_SESSION['form_error']) > 0){
echo '<ul>';
foreach($_SESSION['form_error'] as $error){
echo '<li>'.$error.'</li>';
}
echo '</ul>';
}
?>
and the formhandler which handles the redirection & validation
include("include/session.php");
$_SESSION['formdata']=$_POST;
include("connect.php");
//array to hold form errors
$form_error = array();
//validate your form data
if(!isset($_POST['firstname'])){
$form_error[] = "No first name entered";
}
if(!isset($_POST['secondname'])){
$form_error[] = "No second name entered";
}
if(count($form_error) > 0){
//hold the error in session so you can display the error in your form page.
$_SESSION['form_error'] = $form_error;
//redirect to the form
header("Location: http://www.mindseyemidlands.co.uk/notts_quality/info_resource/selfassess_page1a_v1.php");
} else {
the error message on the form page reads:
Undefined index: form_error in /disk1/home3/mindseye/public_html/notts_quality/info_resource/selfassess_part1a_v1.php on line 689
which refers to the code above
I tried declaring the variable $form_error = array() at the top of the form but the same error occurs
thankyou in advance