SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Clearing form data

    After a user presses 'submit' and their form data is sent off the user receives a thank you page.
    However if they use the back button the form data is still there. How do we remove the form data after 'submit' is selected?
    HTML Code:
    <form method="post" action="/PetalsandPatches/feedback150508.php"> 
     <label>Name*:</label><input name="name" type="text" size="47" />
     <br /><br />
     <label>Address*:</label><input name="address" type="text" size="47" />
     <br /><br />
     <label>City/Town*:</label><input name="city" type="text" size="47" />
     <br /><br />
     <label>State*:</label><input name="state" type="text" size="47" />
     <br /><br />
     <label>Post code*:</label><input name="postcode" type="text" size="47" />
     <br /><br />
     <label>Country*:</label>
     <select name="country" size="1">
    .........................
     </select>
     <br /><br />
     <label>E-mail:</label><input name="email" type="text" size="47" />
     <br /><br />
     <input type="submit" value="Order Catalogue">
    </form>
    ========================
    Carn the Tiges!
    www.petalsandpatches.com

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's no guaranteed way, since the browser may reload the page from its cache.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh dear. What a pity.
    ========================
    Carn the Tiges!
    www.petalsandpatches.com

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can try sending a Cache-Control: no-store HTTP header, plus an Expires date in the past, but even that's no guarantee.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you can create session -->
    works 100&#37;;

    session_start(); //in header
    when you submit page :
    $_SESSION['formhandler']=1;
    on form page put this code :
    <?
    if(isset($_SESSION['formhandler']))
    {
    print "form already submitted..\n";
    unset($_SESSION['formhandler']);
    }else{
    //here your html form ;
    }

    ?>

    CHEERS !!

    Check this :

  6. #6
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    That still requires the browser to load the page from the server, rather thant the cache.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  7. #7
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you object oriented programmer ... do following .. create header class : I use header.class.php
    create function in your class :
    <?
    function clean_headers();
    {
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); //yo can add this header if you want to set expiration date ...
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', FALSE);
    header('Pragma: no-cache');
    }
    ?>

    then simple call to your function in page loaded before your html called ... Play with headers .

    It was kinda bump .


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •