Jump to content

Archived

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

evon83

need help! please check my code!

Recommended Posts

This is my sample code:

Page1:

<?php
   
session_start();
?>

<form action="session2.php?" method="Post">
        <table align="center" border=0 cellspacing=5 cellpadding=0 width="100%">


        <table>
          <tr>
          <th align="left">Address :</th>
              <td><input type="text" size = "55" name="address1"/></td>
              <td><input type="text" size = "55" name="address2"/></td>
          </tr>
        </table>
        <center><input type="submit" name="submit" value="Submit"><input type="reset" Value="Reset"/></center>
        </form>


page2:
<?php
// page1.php

session_start();

$_session['address1']=$_POST['address1'];
$_session['address2']=$_POST['address2'];

echo "1:".$_session['address1'];
echo "
2:".$_session['address2'];

session_destroy();

-------------------------------------------

my question is:
after i have clicked on page2....i wanna go back to page1, so click on the back button...
and when i do that, the data that i have keyed in previously has been erased automatically....
how to keep my previous data??

please help!

thanks!
 


Share this post


Link to post
Share on other sites
Try This

header("Cache-control: private");

[quote]<?php
 
session_start();

[color=red]header("Cache-control: private");[/color]
?>

<form action="session2.php?" method="Post">
        <table align="center" border=0 cellspacing=5 cellpadding=0 width="100%">


        <table>
          <tr>
          <th align="left">Address :</th>
              <td><input type="text" size = "55" name="address1"/></td>
              <td><input type="text" size = "55" name="address2"/></td>
          </tr>
        </table>
        <center><input type="submit" name="submit" value="Submit"><input type="reset" Value="Reset"/></center>
        </form>


page2:
<?php
session_start();

[color=red]header("Cache-control: private");[/color]
// page1.php
$_session['address1']=$_POST['address1'];
$_session['address2']=$_POST['address2'];

echo "1:".$_session['address1'];
echo "
2:".$_session['address2'];

session_destroy();[/quote]

Share this post


Link to post
Share on other sites

×

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.