Guest User

Untitled

a guest
Dec 18th, 2014
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.33 KB | None | 0 0
  1. <link rel="stylesheet" type="text/css" href="style.css">
  2. <?php
  3. include 'functions.inc';
  4. if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
  5.     $user_login_file = 'existing_users.dat';
  6.     $handle = fopen($user_login_file, "r");
  7.     if ($handle) {
  8.         while (($line = fgets($handle)) !== false) {
  9.             //process the line read
  10.             $parts = explode(',', $line);
  11.             if ($_SESSION['username'] == $parts[0]) {
  12.                 echo "Logged in as " . $parts[0] . " (" . $parts[3] . ") Not you? <a href='destroy.php'>Logout</a>";
  13.             }
  14.         }
  15.     }
  16.        fclose($handle);
  17. }
  18. else {
  19.     print "Have an account? <a href='login.php'>Login here</a><br>";
  20.      print "First time ordering? <a href='register.php'> Register</a>";
  21.  }
  22. $pizza = [
  23.     [
  24.         'image' => 'ZaABHrY.jpg',
  25.         'type' => 'Hand Tossed',
  26.         'price' => 12,
  27.         'size' => [
  28.             ["name" => "Small", "price" => 10],
  29.             ["name" => "Medium", "price" => 12],
  30.             ["name" => "Large", "price" => 14],
  31.             ["name" => "X-Large", "price" => 16]
  32.         ]
  33.     ],
  34.     [
  35.         'image' => 'fqmDhym.jpg',
  36.         'type' => 'Crunchy Thin Crust',
  37.         'price' => 12,
  38.         'size' => [
  39.             ["name" => "Small", "price" => 10],
  40.             ["name" => "Medium", "price" => 12],
  41.             ["name" => "Large", "price" => 14],
  42.             ["name" => "X-Large", "price" => 16]
  43.         ]
  44.     ],
  45.     [
  46.         'image' => 'VMXXpAo.jpg',
  47.         'type' => 'Hand Made Pan',
  48.         'price' => 12,
  49.         'size' => [
  50.             ["name" => "Small", "price" => 10],
  51.             ["name" => "Medium", "price" => 12],
  52.             ["name" => "Large", "price" => 14],
  53.             ["name" => "X-Large", "price" => 16]
  54.         ]
  55.     ]
  56. ];
  57. ?>
  58. <html>
  59.     <head>
  60.         <meta charset="UTF-8">
  61.         <title>Pizza Palooza</title>
  62.     </head>
  63.     <body>
  64.     <br><center><div class='page_title'><h1>Pizza Palooza</h1></div></center><br>
  65.         <form method ="post" action="cheese.php">      
  66.             <?php
  67.             if(isset($_POST['next_button'])){
  68.                 if (isset($_POST['size'])) {
  69.                 $s = explode("_", $_POST['size']);
  70.                 $_0 = $s[0];
  71.                 $_1 = $s[1];
  72.                 // The above is purely so it's more readable
  73.                 echo "You selected a " . $pizza[$_0]['size'][$_1]['name'] . " " . $pizza[$_0]['type'] . " pizza for $" . $pizza[$_0]['size'][$_1]['price'];
  74.             }
  75.             else{
  76.                 header('Location:index.php');
  77.             }
  78.             }          
  79.             ?>
  80.             <center>
  81.             <table border="1" align='center'>
  82.                 <tbody>
  83.                     <?php // table column labels  ?>
  84.                     <tr>
  85.                         <td style="text-align: center"><b><big>Image</big></b></td>
  86.                         <td style="text-align: center"><b><big>Crust Type</big></b></td>
  87.                         <td style="text-align: center"><b><big>Size</big></b></td>
  88.                     </tr>
  89.                     <?php
  90. // number of products is the count of $pizza
  91.                     $numb_products = count($pizza);
  92.                     $size_string = "";
  93. // loop printing info about pizzas in table
  94.                     for ($i = 0; $i < count($pizza); $i++) {
  95.                         if (empty($quantities)) {
  96.                             foreach ($pizza[$i]['size'] as $k => $s) {
  97.                                 $size_post = $i . "_" . $k;
  98.                                 $size_string .= "<input type=radio name='size' value='$size_post'";
  99.                                 $size_string .= isset($_POST['size']) ? ($_POST['size'] == $i . "_" . $k ? " checked='checked'" : "") : "";
  100.                                 $size_string .= ">" . $s['name'] . " ($" . $s['price'] . ")<br>";
  101.                                 if (isset($errors['size'][$i])) {
  102.                                     $size_string .= "<span style='font-style:italic;font-size:8px;color:red;'>{$errors['size'][$i]}</span>";
  103.                                 }
  104.                             }
  105.                             // format table with printf
  106.                             printf('
  107.                             <tr>
  108.                                 <td><img alt="Small" id="lightboxImage"
  109.                                         style="width: 119px; height: 88px;"
  110.                                         src="http://i.imgur.com/%s"
  111.                                         height="300" width="300"></td>
  112.                                 <td style="text-align: center;">%s</td>
  113.                                 <td style="text-align: left;">' . $size_string . '</td>
  114.                             </tr>
  115.                             ', $pizza[$i]['image'], $pizza[$i]['type'], $pizza[$i]['price']);
  116.                             $size_string = "";
  117.                         }
  118.                     }
  119. // row with Purchase button
  120.                     ?>
  121.                     <tr><td colspan="5" style="text-align: right" border="none">
  122.                             <input type="button" name="back_button" value="Back" colspan="5" style="text-align: right" border="none" onclick="window.location = 'home.php'">
  123.                             <input type="submit" name="next_button" value="Next" onclick="window.location = 'cheese.php'">
  124.                         <?php                           // var_dump($_POST); ?>
  125.                         </td>
  126.                     </tr>
  127.                 </tbody>
  128.             </table>
  129.     </center> </form>
  130. </body>
  131. </html>
Advertisement
Add Comment
Please, Sign In to add comment