webref.eu Posted August 19, 2008 Share Posted August 19, 2008 Hi All I have a form that takes user input and posts back to itself. Once the form input has been validated, it inserts the data into my database. At this point I effectively want to stop the script running, and show a msg that says "Thanks for your input". At the moment, even after the validation and insert has been done, the form is incorrectly displayed again, just because the page is posting back and the form html appears at the bottom of the page. So, what's the best way to interrupt processing and display the user msg? I tried using a statement like: header("Location: $newpage"); but it didn't like that. Thanks All. Link to comment https://forums.phpfreaks.com/topic/120362-solved-how-to-end-form-processing-on-success/ Share on other sites More sharing options...
MatthewJ Posted August 19, 2008 Share Posted August 19, 2008 Generally you wrap the enire page contents in an if statement... Then, if the data validates and gets posted to the db, display the success message, if not load the form again. Link to comment https://forums.phpfreaks.com/topic/120362-solved-how-to-end-form-processing-on-success/#findComment-620117 Share on other sites More sharing options...
revraz Posted August 19, 2008 Share Posted August 19, 2008 echo "Thanks for your input"; exit; Header won't work if you already sent output to the browser, but you can use a HTML or Javascript redirect. Link to comment https://forums.phpfreaks.com/topic/120362-solved-how-to-end-form-processing-on-success/#findComment-620128 Share on other sites More sharing options...
webref.eu Posted August 19, 2008 Author Share Posted August 19, 2008 OK, thanks everybody. Link to comment https://forums.phpfreaks.com/topic/120362-solved-how-to-end-form-processing-on-success/#findComment-620157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.