After PHP Form Validation, How to Move Forward???

[size=10pt]I need to validate some form field info like name, address, zip, email, etc. I am trying to use the process set forth here at W3Schools.com: w3schools.com/php/php_form_validation.asp

I’ve also found several “tutorials” on the subject, most using the same process. This process actually works pretty well. . . . .if there is an error. However, not one single one of the “tutorials,” including W3Schools tell you how to move to the “process” page if/when all of the fields pass the validation. They all use a form action that uses the super global variable “$_SERVER[“PHP_SELF”].” So the form can never leave the form page!

How do I get the form to advance to the process page if the fields pass the validation process?

Thanks!

Ron in Oregon[/size]

try this

something like that should work…change the ‘self’ stuff to the page you want to go to.

[size=10pt]That’s how the form was set up before I began the validation process but this advances the form regardless of errors when the “submit” button is clicked. The reason for the “self” page action is so that the form process is halted due to errors and the form is re-displayed so that the user will will see the error messages telling them that they need to fix something.

I think the solution came to me during the night while sleeping (isn’t that how it works! :wink: ) If I create a PHP variable, say $page and set it’s value to the page I want to move to if there are no errors, then in the validation process if an error is encountered I change it to the “self” page. In the form action I will use the variable $page. That way if there are errors, the form will re-display with the errors and if there are no errors, the form should advance to the process page. I’ll test it today or tomorrow.

Thanks!
[/size]

Sponsor our Newsletter | Privacy Policy | Terms of Service