NerdConcepts Posted September 4, 2007 Share Posted September 4, 2007 I've looked everywhere and cannot find my answer. After a successful form submission it tells the admin it was successful but then I want the form to clear out. Because I do have it where the data is redisplayed in the form just in case of an error. But when there isn't an error and the form is processed it still shows the POST data...anyway to clear this out? Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/ Share on other sites More sharing options...
TheFilmGod Posted September 4, 2007 Share Posted September 4, 2007 Please show your code. All you do is take out the the post date from the <input value="...">. Its all in the code... Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341594 Share on other sites More sharing options...
trq Posted September 4, 2007 Share Posted September 4, 2007 Sounds more like a logic problem to me. Why are you displaying the form again after success? Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341595 Share on other sites More sharing options...
teng84 Posted September 4, 2007 Share Posted September 4, 2007 use header file or unset Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341597 Share on other sites More sharing options...
TheFilmGod Posted September 4, 2007 Share Posted September 4, 2007 Sounds more like a logic problem to me. Why are you displaying the form again after success? Thorpe is completely right. You should code php in such a way that if success is performed then a messag is shown and no inputs... Here is an example of self processing form: <?php if (isset($_POST['submit'])) { process form... Create an array $error and store error messages corresponding to a key. - if an error occurs // If errors were made... If (is_array($error)) { Show form with errors } else { echo "Success. Form submitted without errors!"; } } else { show form... } ?> Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341601 Share on other sites More sharing options...
teng84 Posted September 4, 2007 Share Posted September 4, 2007 Sounds more like a logic problem to me. Why are you displaying the form again after success? Thorpe is completely right. You should code php in such a way that if success is performed then a messag is shown and no inputs... Here is an example of self processing form: <?php if (isset($_POST['submit'])) { process form... Create an array $error and store error messages corresponding to a key. - if an error occurs // If errors were made... If (is_array($error)) { Show form with errors } else { echo "Success. Form submitted without errors!"; } } else { show form... } ?> i believe what he wants is to remove the post data on each form and have the form empty with the message success i guess it should be if (isset($POST['button'])) { do something if sucess--- header('location: put the same address here to remove the post data'); else retain the post data or dont do the header file } Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341624 Share on other sites More sharing options...
Fadion Posted September 4, 2007 Share Posted September 4, 2007 Im with teng84's opinion. He has textboxes filled with post values in case the submit doesnt pass validation, so the user doesnt have to refill the info. A redirect will do it, with header() or meta refresh. Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341629 Share on other sites More sharing options...
NerdConcepts Posted September 4, 2007 Author Share Posted September 4, 2007 The header (redirect) is what I'm going with. I just know that clients will get tired of forgetting to fill in a value, hitting submit and then having to retype all the information and select all the photos again. Thanks. Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341650 Share on other sites More sharing options...
d22552000 Posted September 4, 2007 Share Posted September 4, 2007 header("REDIRECT 201 (ADDPAGENAMEHERE)"); This iwll redirect with the status code "CONTINUE" which will keep the browser waiting untill the next page says its loaded fine, if the page it redirects to doesnt load then it iwll point the user bakc to the form. Link to comment https://forums.phpfreaks.com/topic/67962-solved-how-to-clear-post-data/#findComment-341678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.