Ok, so go to
http://dev.heatedblades.com/vehicles.php (fyi there is absolutely no PHP on this page).
Add a product to the cart, any product. The action page for the form is cart_add.php
Source for cart_add.php:
PHP Code:
<?php
session_start();
switch($_GET['product']){
case 'complete_set':
$_SESSION[] = array(1, 49.95, 7.95, 'Heat Flexx Complete Set', $_GET['driver'], $_GET['passenger']); //1 is the quantity
break;
case 'single_blade':
$_SESSION[] = array(1, 24.95, 7.95, 'Heat Flexx Single Blade Only', $_GET['blade_size']);
break;
case 'wiring_kit':
$_SESSION[] = array(1, 6.95, 4, 'Heat Flexx Wiring Kit Only');
break;
}
echo print_r($_SESSION);
header("Location: ../cart.php");
?>
Ok, so as you can see with the print_r function the array populated correctly. The redirect to the cart page didn't work because of the print_r output, so hit back and click on "View Cart" in the navbar.
Source for cart.php:
PHP Code:
<?php
session_start();
print_r($_SESSION);
switch($_POST['submit']){
case 'empty':
session_unset();
break;
case 'update':
for($i = 1; $i < $_SESSION['cartnext']; ++$i){
if($_SESSION[$i]){
$quant = 'quantity' . $i;
if($_POST[$quant] != $_SESSION[$i][0] && is_numeric($_POST[$quant])) $_SESSION[$i][0] = number_format($_POST[$quant], 0);
if(!$_SESSION[$i][0] || $_POST['remove' . $i]) unset($_SESSION[$i]);
}
}
break;
case 'checkout':
header("Location: https://" . $_SERVER['SERVER_NAME'] . "/customer_info.php");
exit();
break;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- InstanceBegin template="/Templates/main_template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Heated Blades for Windshiled Wipers</title>
<!-- InstanceEndEditable -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
form {
margin: 0px;
}
-->
</style>
<!-- InstanceEndEditable -->
</head>
<body onload="MM_preloadImages('images/nav-gradient-overlay.png');MM_preloadImages('/images/order_on.png')">
<div class="trackers">
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-11037093-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<noscript>
<div style="display:inline;"> <img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1031538361/?value=30.0&label=bll_CI2iqwEQuY3w6wM&guid=ON&script=0"/> </div>
</noscript>
</div>
<div class="mainstripe">
<div class="container">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/heat-flexx-logo.png" width="310" height="175" alt="Heated Blades for Windshiled Wipers" /></td>
<td><img src="images/blade-comparison.jpg" alt="Heat Flexx Blade Comparison" width="469" height="175" class="sideborder" /></td>
</tr>
</table>
</div>
</div>
<div class="navstripe stripeborder">
<div class="container blackback" align="center">
<div class="nav-item" style="width:111px;""><a href="index.php">Home</a></div>
<div class="nav-item"><a href="vehicles.php">Vehicle List</a></div>
<div class="nav-item"><a href="instructions.php">Instructions</a></div>
<div class="nav-item"><a href="contact.php">Contact</a></div>
<div class="nav-item"><a href="resellers.php">Resellers</a></div>
<div class="nav-item"><a href="/fleet.php">Fleet</a></div>
<div class="nav-item" style="width:112px"><a href="/cart.php">View Cart</a></div>
<div class="clear-both"></div>
</div>
</div>
<div style="background-color:#FFFFFF">
<div class="container">
<div class="main"><!-- InstanceBeginEditable name="Main_Edit" -->
<?php
if(!$_SESSION['cartnext']) echo '
<div style="min-height:400px">
<h1 align="center">Your cart is currently empty.</h1>
<h2 align="center" style="margin-bottom:0px"><a href="/vehicles.php">Return to Vehicle List</a></h2>
</div>';
else { echo '
<h1 align="center">HeatedBlades.com Shopping Cart</h1>
<form action="" method="post" name="cartform">
<table width="781" border="0" cellspacing="0" cellpadding="10">
<tr class="header-text">
<td align="center" width="461">Product</td>
<td align="center" width="80">Quantity</td>
<td align="center" width="80">Remove?</td>
<td align="center" width="80">Price</td>
</tr>';
$shipping = 0;
for($i = 1; $i < $_SESSION['cartnext']; ++$i){
if($_SESSION[$i]){
echo '
<tr>
<td>';
if($_SESSION[$i][3] == 'Heat Flexx Complete Set' || $_SESSION[$i][3] == 'Heat Flexx Single Blade Only'){
echo '
<table width="461" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><strong>' . $_SESSION[$i][3] . '</strong></td>
<td align="right">';
switch($_SESSION[$i][3]){
case 'Heat Flexx Complete Set':
echo 'Driver: ' . $_SESSION[$i][4] . ' Passenger: ' . $_SESSION[$i][5];
break;
case 'Heat Flexx Single Blade Only':
echo 'Blade Size: ' . $_SESSION[$i][4];
break;
}
echo '</td>
</tr>
</table>';
}
else {
echo '<strong>' . $_SESSION[$i][3] . '</strong>';
}
echo '
</td>
<td align="center"><input name="quantity' . $i . '" type="text" size="2" maxlength="2" value="' . $_SESSION[$i][0] . '" /></td>
<td align="center"><input name="remove' . $i . '" type="checkbox" /></td>
<td align="center">$' . number_format($_SESSION[$i][1], 2) . '</td>
</tr>';
$shipping += $_SESSION[$i][2];
}
}
echo '
<tr class="header-text">
<td align="right" colspan="3">Sub-Total:</td>
<td></td>
</tr>
<tr>
<td colspan="2"><em>*Illinois Residents will have 6.25% Sales Tax added at checkout.</em></td>
<td align="right" style="font-size:large">Shipping:</td>
<td style="font-size:large"></td>
</tr>
<tr class="header-text">
<td align="right" colspan="3">Total:</td>
<td></td>
</tr>
<tr>
<td colspan="4" align="right"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input value="checkout" name="submit" type="image" onmouseover="this.src=\'images/checkout_on.png\'" onmouseout="this.src=\'images/checkout_off.png\'" src="images/checkout_off.png" alt="Heated Blades" /></td>
<td width="20"></td>
<td><input value="empty" name="submit" type="image" onmouseover="this.src=\'images/empty_cart_on.png\'" onmouseout="this.src=\'images/empty_cart_off.png\'" src="images/empty_cart_off.png" alt="Heated Blades" /></td>
<td width="20"></td>
<td><input value="update" name="submit" type="image" onmouseover="this.src=\'images/update_cart_on.png\'" onmouseout="this.src=\'images/update_cart_off.png\'" src="images/update_cart_off.png" alt="Heated Blades" /></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4" align="center">If you want to add more blades for your other cars that are different lengths, <a href="/vehicles.php">return to the vehicles page</a> and add to cart again with your other blade sizes. Changing your quanity will get you more blades of the same sizes.</td>
</tr>
</table>
</form>';
}
?>
<!-- InstanceEndEditable --></div>
<div class="clear-both"></div>
</div>
</div>
<div class="footerstripe stripeborder">
<div class="container"> </div>
</div>
<div class="footstripe">
<div class="container" align="center" style="font-weight:bold; font-size:small">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="75">©2009 HeatedBlades.com All Rights Reserved. </td>
</tr>
</table>
</div>
</div>
</body>
<!-- InstanceEnd -->
</html>
So as you can see print_r is almost the first thing on this page. But the array I've stored in my session has magically disappeared! No matter what I try, the array always disappears. Why?