php/html working with forms

Soldato
Joined
1 Feb 2006
Posts
8,188
hi guys,

just been having a big read through some stuff lately on handling forms/validation/redirects etc.

What way would you best recommend to handle the control of events after a form has been submitted. Is it best to use a..

Code:
header ("location:http://www.site.com");

to redirect back to the site index for example or should I have a 'your data has been submitted' page where the user can navigate to wherever they wish. I'm not too sure what is best for this. Originally I would have used a javascript alert being executed from within my PHP code but this is useless for javascript disabled users.

Also, if i do use a php header redirect can a user press the back button and review the form? I really think this is very messy and can lead to double form submissions which is real not what i want.

Any advice or best practices on this would be good. I have had a google and came up with the header redirects but looking some advice from the pros on here. Thanks
 
I guess I could just simply echo out the html from php and then have a 'you will now be directed to...' page. Is there any way I can ensure that the user can't navigate back to the form and resubmit it? Perhaps breaking the navigation is bad practice though.
 
thanks for the info guys... what i have here myself is

1) User fills out form and submits
2) Form is posted to self and validated.
3) Once information is valid and processed then success message appears on same page
4) User redirected to home page

This works nicely but I will have to work on something to stop the user being able to navigate back to the form. Would be ok to do with a database but im thinking of something like contact form scripts where no unique identifier is used. I guess the average user won't be pressing back anyways once they see the success message.
 
Back
Top Bottom