3rdTimeLucky
Programmer
Hi there.
I've got this problem sorted, but I just need a little advice regarding the performance of my solution.
I have a 3 page registration form for new customers:
Page 1 - Personal Details
Page 2 - Medical Details
Page 3 - Payment Details
Now I have written a function validate_form.php that basically takes a hidden "required" and "redirect" field from each form and checks that none of the field values in the "required" list (comma separated) are blank.
If any of the required fields are blank, the script does a header("Location: " . $_SERVER['HTTP_REFERER']); call and displays an error message on the page the user has just come from. If they are all ok, the script goes to the page listed in "redirect".
Now, the issue was, that if the user was sent back to page they just filled out, i wanted the data they had already entered to still be there. So I registered all of the $_POST variables as Session variables using this:
So obviously this works no problem. Just display the Session vars in the text boxes when the user is sent back.
My question is, as the processing of the registration progresses, should I be unregistering these variables in favour of hidden form variables?
I'm thinking about both performance and security here, and I am unsure of the implications my solution will have in either of these departments.
Thanks in advance
Aaron
I've got this problem sorted, but I just need a little advice regarding the performance of my solution.
I have a 3 page registration form for new customers:
Page 1 - Personal Details
Page 2 - Medical Details
Page 3 - Payment Details
Now I have written a function validate_form.php that basically takes a hidden "required" and "redirect" field from each form and checks that none of the field values in the "required" list (comma separated) are blank.
If any of the required fields are blank, the script does a header("Location: " . $_SERVER['HTTP_REFERER']); call and displays an error message on the page the user has just come from. If they are all ok, the script goes to the page listed in "redirect".
Now, the issue was, that if the user was sent back to page they just filled out, i wanted the data they had already entered to still be there. So I registered all of the $_POST variables as Session variables using this:
Code:
// Assign all the form variables to an array
$aFormVars = &$HTTP_POST_VARS;
// Set all passed variables to session variables
foreach ($aFormVars as $key => $field) {
session_register($key);
$_SESSION[$key] = $field;
}
So obviously this works no problem. Just display the Session vars in the text boxes when the user is sent back.
My question is, as the processing of the registration progresses, should I be unregistering these variables in favour of hidden form variables?
I'm thinking about both performance and security here, and I am unsure of the implications my solution will have in either of these departments.
Thanks in advance
Aaron