Jump to content

[SOLVED] How to clear POST data?


NerdConcepts

Recommended Posts

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

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...     

}
?>

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

}

 

 

 

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. :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.