Jump to content

Conditional Post to another php page


Deepzone

Recommended Posts

With strictly PHP I do not believe this to be possible since the form handler would need to process the form before determining if any errors occurred.

A better approach would be to handle both the form and any errors that occur on the landing page.

Javascript validation is not reliable. The user may choose to turn off Javascript.

 

The best approach (IMO) is to post to the same page and process the data. If an error occurs, you can show the form, with the user's supplied data so they don't have to re-type everything, just the invalid stuff.

 

If there are no errors you can use PHP to redirect to the final page:

header('Location: http://www.mydomain.com/thankyou.php');
exit();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.