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

}
?>

Link to comment
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...     

}
?>

 

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