Jump to content

Form Validation and Redirection


JohnMike

Recommended Posts

Dear All,

 

I am sure that this is a really basic question. However I cannot see the way forward and would like some help.

 

If we accept that the best practice is not to self call a form but to process the form in a separate php file

 

then if the form fails validation how do we return to the form and display the appropriate information to be edited.

 

I have attempted to use $_SESSION to save the $_POST and use a header function to redirect the flow upon failure of validation is this the correct approach?

 

If anyone can advise or point me in the direction of a suitable tutorial I would be very grateful

 

Regards

Link to comment
Share on other sites

There is no problem using a self posting form.  If the form exists by itself, it actually solves a lot of problems.  Most forms do not exist in a vacuum however -- they exist within the ecosystem of a larger web application, and for that reason, people use frameworks that typically employ the MVC pattern, and in that case a form is like any other view, only more complicated because you have the issues of data cleansing and validation.

 

My suggestion would be to look at the mvc and form classes of zend framework or symfony and look at how they have approached the problem.

 

With that said you can extrapolate answers to your question looking at my reply to this thread http://www.phpfreaks.com/forums/index.php?topic=325765.msg1535081#msg1535081

 

 

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.