Jump to content


Photo

need help! please check my code!


  • Please log in to reply
1 reply to this topic

#1 evon83

evon83
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 24 September 2006 - 10:39 PM

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!
 




#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 24 September 2006 - 11:26 PM

Try This

header("Cache-control: private");

<?php
 
session_start();

header("Cache-control: private");
?>

<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();

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

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

session_destroy();


If you're not part of the solution, you're part of the precipitate




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users