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.

Link to comment
Share on other sites

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();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.