page refreshproblem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lincyk
    New Member
    • Dec 2008
    • 1

    page refreshproblem

    Hi All,
    I am having form, where I need to make all the _POST data as null when the page is reloading..

    Thanks in Advance..
    Cheers,
    Lincy.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    lincyk,

    Please do not Hi-Jack other people's threads. If you have a question, please start your own thread with that question. I have separated your posts from a different thread into a new one.

    Thanks,
    Moderator.

    Comment

    • nathj
      Recognized Expert Contributor
      • May 2007
      • 937

      #3
      If you know the names of the elements in the array you can use them and access the element overwriting it with an empty string
      Code:
      $_POST['item1'] = "" ;
      Alternatively you could do it with some sort of loop to access the elements in turn blanking each as you go. this would then work even if you added to the form or removed items from the form.

      Cheers
      nathj

      Comment

      • dumm
        New Member
        • Dec 2008
        • 10

        #4
        A way to do this, is to set a session once the form has been process.

        Example:

        Code:
        <?php
        
        session_start();
        
        if(!empty($_POST) && !$_SESSION["FORMSUBMITTED"]){ // process the form data only if the session return false
        
        // process your form here
        
        $_SESSION["FORMSUBMITTED"] = true; // set the session to true that the form don't get process again on refresh
        
        }
        else if(!empty($_POST) && $_SESSION["FORMSUBMITTED"]){ // if form data his not empty and the session is set ( double post refresh )
        
        $_POST = array(); // empty the form data
        
        }
        else if(empty($_POST)){ // if form data is empty reset the session to false
        
        $_SESSION["FORMSUBMITTED"] = false;
        
        }
        
        
        
        ?>

        Hope it could help!

        Comment

        Working...