PHP5/PHP Error Messages
I have this code https://gist.github.com/burn123/5009737. It is basically a question and answer type code, and it is working fine right now. I was wondering how to put the error messages on index.html, so I don't have to do a separate page load for them. So they would only go on to q1.php if they got the right answer
Hi Cody. Please see the code at http://pastebin.com/kSJb9QWK
This is nice easy, beginner type of code, coded so that it should be fairly easy to follow.
Essentially, what you'll do is check to see if the request was a POST submission. If so, check the posted value to see if it matches. If not, set $error to your error message. If it does match, redirect to q2.php where you can do the same exact thing.
Then, when displaying your form, if $error isn't empty, echo it before the form.
I hope you can follow the code. It is untested, but should work.
Please let me know if you have any other questions :)