Guest User

Untitled

a guest
May 27th, 2010
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.29 KB | None | 0 0
  1. <?
  2. include("includes.php");
  3. session_start();
  4. /**************************************************************************************************
  5. * Server PHP Kit Build Order Page
  6. ***************************************************************************************************
  7.  
  8. ***************************************************************************************************
  9. * Change history
  10. * ==============
  11. *
  12. * 10/02/2009 - Simon Wolfe - Updated for protocol 2.23
  13. * 18/10/2007 - Nick Selby - New kit version
  14. ***************************************************************************************************
  15. * Description
  16. * ===========
  17. *
  18. * Displays details of the products and allows the user to enter a number of each item to buy.  
  19. * It then validates the selection and forwards the user to the customer details page.
  20. ***************************************************************************************************/
  21.  
  22. // Check for the proceed button click, and if so, go validate the order
  23. if ($_REQUEST["navigate"]=="proceed"){
  24.     /** We need the user to have selected at least one item, so let's see what they've chosen **
  25.     *** by looping through the submitted Quanity fields **/
  26.     $strCart="";
  27.     for ($iLoop=1; $iLoop <= count($arrProducts); $iLoop++) {
  28.         $strQuantity = "Quantity" . $iLoop;
  29.         $strThisQuantity=$_REQUEST[$strQuantity];
  30.         if ($strThisQuantity>0) {
  31.             $strCart=$strCart . $strThisQuantity . ",";
  32.         }
  33.     }
  34.    
  35.     if (strlen($strCart)==0){
  36.         // Nothing was selected, so simply redesiplay the page with an error
  37.         $strPageError="You did not select any items to buy.  Please select at least 1 DVD.";
  38.         $_SESSION["strCart"]="";
  39.     }
  40.     else  {
  41.         // Save the cart to the session object
  42.         $_SESSION["strCart"]=$strCart;
  43.         // Proceed to the customer details screen
  44.         ob_end_flush();
  45.         redirect("customerDetails.php");
  46.     }
  47. }
  48. else if ($_REQUEST["navigate"]=="back") {
  49.     ob_end_flush();
  50.     redirect("welcome.php");
  51. }
  52.  
  53. // If we have a cart in the session, then we'll show the selected items here **
  54. $strCart=$_SESSION["strCart"];
  55.  
  56. ?>
  57. <html>
  58. <head>
  59.     <title>Form PHP Kit Build Order Page</title>
  60.     <link rel="STYLESHEET" type="text/css" href="images/formKitStyle.css">
  61.     <script type="text/javascript" language="javascript" src="scripts/common.js" ></script>
  62. </head>
  63.  
  64. <body>
  65.     <div id="pageContainer">
  66.         <? include "header.html"; ?>
  67.         <? include "resourceBar.html"; ?>
  68.         <div id="content">
  69.             <div id="contentHeader">Creating an Example Order</div>
  70.             <p>This page demonstrates how to  create a very simple basket of goods. Use the form below to select the number of each DVD title you wish to buy, then hit Proceed. You have to select at lest 1 DVD to continue. </p>
  71.             <p>The title, price and DVD ID (used to display the correct image) are extracted from a simple array and used to build the table. You can view this code in the buildOrder.php page.</p>
  72.             <div class="greyHzShadeBar">&nbsp;</div>
  73.             <? if (isset($strPageError)) { ?>
  74.             <div class="errorheader">
  75.                 <? echo $strPageError ?>
  76.             </div>
  77.             <? } ?>
  78.             <form action="buildOrder.php" method="POST" name="mainForm">
  79.                 <input type="hidden" name="navigate" value="" />
  80.                 <table class="formTable">
  81.                     <tr>
  82.                         <td colspan="4"><div class="subheader">Please select the quantity of each item you wish to buy</div></td>
  83.                     </tr>
  84.                     <tr class="greybar">
  85.                         <td width="15%" align="center">Image</td>
  86.                         <td width="55%" align="left">Title</td>
  87.                         <td width="20%" align="right">Price</td>
  88.                         <td width="10%" align="center">Quantity</td>
  89.                     </tr>
  90.                     <?
  91.                     for ($iIndex=1; $iIndex <= count($arrProducts); $iIndex++) {
  92.                         $strImageId = "00" . $iIndex;
  93.                         echo "<tr>";
  94.                         echo "<td align=\"center\"><img src=\"images/dvd" . substr($strImageId,strlen($strImageId)-2,2) .  ".gif\" alt=\"DVD box\"></td>";
  95.                         echo "<td align=\"left\">";
  96.                         echo $arrProducts[$iIndex-1][0];
  97.                         echo "</td>";
  98.                         echo "<td align=\"right\">" . $arrProducts[$iIndex-1][1] . " " . $strCurrency . "</td>";
  99.                         echo "<td>";
  100.                         echo "<select name=\"Quantity" . $iIndex ."\"";
  101.                         echo "size=\"1\">";
  102.                         echo "<option value=\"0\">None</option>";
  103.                         for ($iLoop=1; $iLoop <= 5; $iLoop++) {
  104.                             $strThisItem=$iLoop . " of " . $iIndex;
  105.                             echo "<option value=\"" . $strThisItem . "\"";
  106.                             // If this is in our cart, show it selected
  107.                             if(strstr($strCart, $strThisItem))  
  108.                             echo " SELECTED";
  109.                             echo ">" . $iLoop . "</option>";
  110.                         }
  111.                         echo "</select>";
  112.                         echo "</tr>";
  113.                     }
  114.                     ?>
  115.             </table>
  116.             <div class="greyHzShadeBar">&nbsp;</div>
  117.             <div class="formFooter">
  118.                 <a href="javascript:submitForm('mainForm','back');" title="Go back to the kit home page" style="float: left;"><img src="images/back.gif" alt="Go back to the kit home page" border="0" /></a>
  119.                 <a href="javascript:submitForm('mainForm','proceed');" title="Submit the order details" style="float: right;"><img src="images/proceed.gif" alt="Proceed to the next page" border="0" /></a>
  120.             </div>
  121.             </form>
  122.         </div>
  123.     </div>
  124. </body>
  125. </html>
Advertisement
Add Comment
Please, Sign In to add comment