Forum Moderators: coopster
User submits a form and it is processed by a php script. This script loads my form validation class, validates the form data and then either continues on to another process(with valid data) or it displays a list of errors.
After displaying the list of errors I would like to return to the form after a certain period of time(10 seconds or so). The form would then have the incorrect fields highlighted by css + php.
The problem I am having is returning back to the form.
I have constructed the list of errors to send back to the form(the field names) and I have figured out how to check that list and highlight the appropriate fields using a php function and a little css. I just cant figure out how to return to the form, with the users previous data still there, along with my list of fields that contain errors.
Does that make sense? :)
Im new to php so I could be missing something simple but can someone point me in the right direction?
Thanks
1st time through $ds is not set. Display form.
2nd time through $ds is set. Run script.
The script then decides whether to show the form with errors highlighted, or to show a thank you page.
Clear as mud?
WBF
That makes sense but Im not submitting the form to itself its going to another script, my problem is getting back to the form and sending my list of errors(I dont want to use javascript).
When I use 'header("Location:...' I get an error that the headers are already sent and I assume that even if that did work the form fields would be empty. Of course you just showed me how I can repopulate them.
Basically I dont know how to return to the form using php.
on the index or content page it includes the form file
processes in a seperate script
on error it reincludes the form file else it goes off to a thanks page
you can also throw all the data into a session and access it from there
you can also have it post to itself for processing (I never do this, I just don't like it)
there are a bunch of ways to do it