i want to enter my info in on the entry screen and proceed to the shop.php and have it show the info.
everything works fine except the session id ( i think )
im fairly new with php so im sure its an simple problem im missing.
[i want it to check the cookie to see if ive already got a previous entry. if i do have a previous cookie entry i want to use that info, if i dont have a previous cookie entry i want to create one. (dont really care about the other stuff) maybe this will be a challenge to somebody else too. would appreciate any positive response.
entry.php
<?
session_start();
session_register("sessionver");
if(!$HTTP_COOKIE_VARS["sessionid"])
{
$sessionver = 2;
}
else
{
$sessionver = 3;
}
echo "sessionver = ".$sessionver."<br>";
?>
<body bgcolor=#FFFFFF>
<form action="shop.php" method=post>
<table bgcolor=#778899 border=0 width="1" height="1">
<tr>
<td align=center width="187" height="26" bgcolor="#C0C0C0">
<p align="left"><b>Product:</b></td>
<td align=right width="317" height="26" bgcolor="#778899">
<select size="1" name="product">
<option value="mouse">Mouse</option>
<option value="keyboard">Keyboard</option>
<option value="monitor">Monitor</option>
</select></td>
</tr>
<tr>
<td align=center width="187" height="26" bgcolor="#C0C0C0">
<b>Quantity::</b></td>
<td align=right width="317" height="26">
<!--webbot bot="Validation" s-data-type="Integer" s-number-separators="," b-value-required="TRUE"
i-maximum-length="4" s-validation-constraint="Greater than or equal to" s-validation-value="0" --><input type="text"
name="quantity" size="6" value="0" maxlength="4" style="text-align: right"></td>
</tr>
<tr>
<td align=center width="187" height="26" bgcolor="#778899">
</td>
<td align=right width="317" height="26">
<input type=submit value="Add to Cart"></td>
</tr>
</table>
</form>
<p> </p>
</body>
shop.php
<?
session_start();
//session_register("session", "scid");
echo $sessionver; / this shows fine /
if ($sessionver = 2)
{
$session = md5(uniqid(rand()));
setcookie("sessionid", $session, time() + 35); / says headers already sent /
}
if ($sessionver = 3)
{
$session = $HTTP_COOKIE_VARS["sessionid"];
}
$table = "inventory"; / for sql implementation later /
echo "session: ".$session."<br>"; / doesn't show $session /
echo "table: ".$table."<br>"; / shows fine /
echo "product: ".$product."<br>"; / shows fine /
echo "quantity: ".$quantity."<br>"; / shows fine /
?>