Why won't this Session Work?
Posted: Tue Feb 28, 2006 3:46 pm
Located at the top of the web page:
Code of the form of the same page.
The following is the php script at the start of the page that the form is directed to.
The following is the table to display the variable.
My PHP Session Settings.

feyd | edited to make code wrap.
Code: Select all
<?php
session_start();
session_register('ekk');
$ekk = "Testing";
?>Code: Select all
<body>
<form id="sessiontest" name="sessiontest" method="post" action="test5.php">
<table width="200" border="1" align="center" summary="Using this form to test the functioning of Session Variables.">
<caption align="top">
Test Form
</caption>
<tr>
<th bgcolor="#C3D2F0">Text</th>
<td><input name="txtfld" type="text" id="txtfld" /></td>
<td> </td>
</tr>
<tr>
<th bgcolor="#C3D2F0">Date</th>
<td><input name="datefld" type="text" id="datefld" /></td>
<td><input name="Button" type="button" onclick="KW_expertCalendar('January','February','March','April','May',
'June','July','August','September','October','November','December','Su','Mo','Tu','We','Th','Fr','Sa','datefld','y','-','mm','-',
'dd','0','0','0','-1','-1','-1','0',this,-1,-1,210,155,'kaosjs/images/leftarrow.gif','kaosjs/images/rightarrow.gif',
'kaosjs/images/leftarrow.gif','kaosjs/images/rightarrow.gif','',0,'kaosjs/cal1.css','#ffffff',1)" value="Insert Date" /></td>
</tr>
<tr>
<td> </td>
<td><div align="center">
<input type="submit" name="Submit" value="Submit" />
</div></td>
<td></td>
</tr>
</table>
</form>
</body>Code: Select all
<?php session_start();?>Code: Select all
<body>
<table border="1" align="center" summary="Table to receive the variable information.">
<caption align="top">
Session Test Results
</caption>
<tr>
<th bgcolor="#C3D2F0">Session Variable </th>
<td>
<?php
if (isset($_SESSION["ekk"])) {
echo $_SESSION["ekk"];
}else {
echo $ekk;
}
?>
</td>
</tr>
<tr>
<th bgcolor="#C3D2F0">Form (txtfld) </th>
<td><?php echo $_POST['txtfld'];?></td>
</tr>
<tr>
<th bgcolor="#C3D2F0">Form (datefld) </th>
<td><?php echo $_POST['datefld'];?></td>
</tr>
</table>
</body>
feyd | edited to make code wrap.