Forum Moderators: coopster
Let say I have a multi page contact form and want to continually check that the data is of the right 'kind'.
To give you an idea of what I mean:
1st page.
Enter name
Enter email
submit>>
2nd page
Enter income
Enter spouse name
submit>>
3rd page
review data entered and submit form.
I was thinking of using $_SESSIONS to pass data from one page to the other. The only thing is that between page 1 and 2 I check the form validity with $_POST['name'] and $_POST['email']. So between page 2 and 3 I cannot use the same function (as the data should be in $_SESSION otherwise it's going to be lost).
How would you go around this? Would you define a variable at the start of the function to assign any $_POST or $_SESSION value to it and then run the check on the variable instead of the $_POST['']?
something like
(isset($_POST['name']))? $name2check = $_POST['name'] : '';
(isset($_SESSION['name']))? $name2check = $_SESSION['name'] : '';
and further down
(isset($name2check))? run check on name : '';
Thanks
le_gber
[edited by: jatar_k at 5:44 pm (utc) on July 4, 2006]
[edit reason] fixed link [/edit]
if(is_clean($_POST["email"])) { //is_clean is a custom function. it returns 1 if clean
$_SESSION["email"] = $_POST["email"];
}
else {
//return error
}