Jump to content

How do Display error message after form is posted


jamesnkk

Recommended Posts

Is it possible in PHP, where the user filled up the entry form and click the submit button, which use the 2nd form to query from the table to see if data is duplicate, if data is not duplicate then update into the table,

but if duplicate it re-driect back to the form where the previous text entry still displayed on the form and then indicate an error message on the form. I tried use header to return to the form, but all the text entry is empty and I can't display error message. Please help.

Link to comment
Share on other sites

I think you'd be best served by making the page submit to itself and then using and IF statement to determine if you need to dispplay that info again for correction or if you should printout a message stating that the data is succuscully entered into the database.

One of the more straight forward and easy to understand ways of doing this is to have a hidden text field (example hidden1) that has a value of for example "secondpass"

When the page loads use an IF to check if hidden1 = "secondpass"

hidden1 will only = secondpass if someone clicks on the submit button, meaning that you will know if the page was loaded from a link (hidden1 = "" or null) or was submitted (hidden1 = "secondpass")

hope that helped
I like to help but sometimes I'm wrong or there is a better way and other times I'm a little vague / hard to follow :(
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.