Tag Archives: UNSERIALIZE

finally, you just need create a php page read everything through your class

finally, you just need create a php page read everything through your class,here is the source code for one of the three shopping cart, for another two cart you just need to change the storeID, it make your job much easy.

<?php
session_start();
require_once(“class_OnlineStore.php”);
$storeID = “COFFEE”;
$storeInfo = array();
if(class_exists(“OnlineStore”))
{
    if(isset($_SESSION[‘currentStore’]))
    {
        $store = unserialize($_SESSION[‘currentStore’]);
    }
    else
    {
        $store = new OnlineStore();    
    }
    $store->setStoreID($storeID);
    $storeInfo =  $store->getStoreInformation();
    $store->processUserInput();
}
else
{
    $ErrorMsgs[]=”The OnlineStore class is not available!”;
    $store = null;
        
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title><?php echo $storeInfo[‘name’]; ?></title>
<link rel=”stylesheet” type=”text/css” href=”<?php echo $storeInfo[‘css_file’]; ?>” />
</head>

<body>
<h1><?php echo htmlentities($storeInfo[‘name’]); ?></h1>
<h2><?php echo htmlentities($storeInfo[‘description’]); ?></h2>
<p><?php echo htmlentities($storeInfo[‘welcome’]); ?></p>

<?php
    $store->getProductList();
    $_SESSION[‘currentStore’] = serialize($store);
?>
</body>
</html>

Advertisements