PDA

View Full Version : have to refresh page to display session variables


cottoneye1256
12-22-2008, 08:51 PM
I have a form page that works fine except... nothing is displayed on page3 unless you change the Privacy Setting to "Accept all Cookies" or hit F5.
Even if different data is re-entered @ a different time you still have to keep changing the settings to "Accept all Cookies" or hit F5, then the data is displayed.

page1.htm => data entered (works fine)
page2.php => data displayed and sends out an email w/variable data(works fine)
page3.php => nothing
(unless you change the cookie settings, refresh page2 then data is displayed on page3)

Is there anything I'm doing wrong so the end user doesn't have to keep hitting F5 on page2
I have a feeling it has to do with the code to display the variables because not just one or two items that aren't displayed it's the entire list.

My current code for page2.php
<?php
session_start();
$_SESSION['example1'] = $_POST[example1_from_page1];
$_SESSION['example2'] = $_POST[example2_from_page1];
?>


<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr><td class="col0_out formheadertext" colspan="5" width="435"><center>Score Information</center></td></tr>

<tr>
<td width="25"></td>
<td class="formfieldtext" width="188">Example 1:</td>
<td class="bodytext" width="272"><b>'.$_SESSION['example1'].'</b></td>
<td class="formfieldtext" width="177">Example 2:</td>
<td class="bodytext" width="32%"><b>'.$_SESSION['example2].'</b></td>
</tr>


email code from page2.php
<?php
$msg = '
<html>
table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr><td class="col0_out formheadertext" colspan="5" width="435"><center>Score Information</center></td></tr>

<tr>
<td width="25"></td>
<td class="formfieldtext" width="188">Category:</td>
<td class="bodytext" width="272"><b>'.$_SESSION['example1'].'</b></td>
<td class="formfieldtext" width="177">Location:</td>
<td class="bodytext" width="32%"><b>'.$_SESSION['example2'].'</b></td>
</tr>
';

//set up the mail
$to = "username@example.com";
$subject = 'Help me please';
$mailheaders = "From: $_POST[name]<No-Name-Entered>" . "\r\n" ;
$mailheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mailheaders .= 'MIME-Version: 1.0' . "\r\n";

mail($to, $subject, $msg, $mailheaders);
?>





My current code for page3.php
<?php
session_start();
?>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<table width="575" border="1" cellspacing="0" cellpadding="0" bordercolor="#000000">

<tr>
<td width="64">
<?php echo '<strong>'.$_SESSION['example1']. '</strong>'; ?>
</td>

<tr>
<td width="64">
<?php echo '<strong>'.$_SESSION['example2']. '</strong>'; ?>
</td>


Is the code to display variables written ok? periods, quotes missing or in the right spot?
Is there another way to write this code??