Self Validating Forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
boomer020475
Forum Newbie
Posts: 1
Joined: Mon Jun 27, 2005 9:33 am

Self Validating Forms

Post by boomer020475 »

I am looking to create a form that validates by posting to itself and then posts to another script if validation is good.

The script would work like the following:
1. User fuills out form and submits the form. The form posts to itself.
2. If there are errors teh form shows again with indications of the errors made.
3. If there are no errors, the form would then post to a second script that would process it.

Any idea how this could be done...?

Any help greatly appreciated... :arrow: :o
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hmmm... if you want PHP to post on your behalf it's tricky.

Here's the way I validate things.

Code: Select all

FORM ---------> Validation/Processing -------------> Results
      ^   submit        |                   success
      |                 | Error
      |                 |
       -----------------
In other words the checking is done in the processing script itself while the POST data is available. If an error is hit a "Location:..." header() send the user back to the form, otherwise, process the data while it's all there. DON'T output anything in the processing script, simply use headers to redirect to success or failure page (i.e., the results or the form again).

So thats 3 scripts.
1. The form
2. Processing/Validation
3. Results

;)
Post Reply