Hi,
I have a survey which is spread over 5 pages. Each page has a form with a next button (which actually submits the form) Each form recieves the values of the ones before from hidden form fields.
I am having some trouble validating this. I have set the page up as follows:
if(!$submit1 == "submit1" || $submit1 == "false"){
include("survey1.php");
}
if($submit1 == "submit1"){
include("survey2.php");
}
if($submit2 == "submit2"){
include("survey3.php");
}
if($submit3 == "submit3"){
include("survey4.php");
}
if($submit4 == "submit4"){
include("survey5.php");
}
I need the validation so that if a field is missing PHO echo's out some text beside the form field. I have done this with the following code:
if($submit2){
if(!$Q1){
$q1error = "true";
$error1 = 1;
}
if($Q1){
$error1 = 0;
}
if(!$Q2){
$q2error = "true";
$error2 = 1;
}
if($Q2){
$error2 = 0;
}
if(!$Q3){
$q3error = "true";
$error3 = 1;
}
if($Q3){
$error3 = 0;
}
$error = $error1 + $error2 + $error3;
if($error = 0)
{
$submit1 == "dontdislay";
$submit2 == "submit2";
}
else{
$submit1 == "submit1";
$submit2 == "dontdisplay";
}
}
This sets the values so that if there are errors they are caught in the page and the form doesnt go to the next page. However, the problem I am having is when the use rhas actually completed the 3 form fields - this would mean $error = 0. However, despite this the form wont submit.
Anyone got any ideas?
Maybe there is a better way to deal with this? I want to avoid using javascript if possible.
Thanks,
Martin