Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <link rel="stylesheet" type="text/css" href="style.css">
- <?php
- include 'functions.inc';
- if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
- $user_login_file = 'existing_users.dat';
- $handle = fopen($user_login_file, "r");
- if ($handle) {
- while (($line = fgets($handle)) !== false) {
- //process the line read
- $parts = explode(',', $line);
- if ($_SESSION['username'] == $parts[0]) {
- echo "Logged in as " . $parts[0] . " (" . $parts[3] . ") Not you? <a href='destroy.php'>Logout</a>";
- }
- }
- }
- fclose($handle);
- }
- else {
- print "Have an account? <a href='login.php'>Login here</a><br>";
- print "First time ordering? <a href='register.php'> Register</a>";
- }
- $pizza = [
- [
- 'image' => 'ZaABHrY.jpg',
- 'type' => 'Hand Tossed',
- 'price' => 12,
- 'size' => [
- ["name" => "Small", "price" => 10],
- ["name" => "Medium", "price" => 12],
- ["name" => "Large", "price" => 14],
- ["name" => "X-Large", "price" => 16]
- ]
- ],
- [
- 'image' => 'fqmDhym.jpg',
- 'type' => 'Crunchy Thin Crust',
- 'price' => 12,
- 'size' => [
- ["name" => "Small", "price" => 10],
- ["name" => "Medium", "price" => 12],
- ["name" => "Large", "price" => 14],
- ["name" => "X-Large", "price" => 16]
- ]
- ],
- [
- 'image' => 'VMXXpAo.jpg',
- 'type' => 'Hand Made Pan',
- 'price' => 12,
- 'size' => [
- ["name" => "Small", "price" => 10],
- ["name" => "Medium", "price" => 12],
- ["name" => "Large", "price" => 14],
- ["name" => "X-Large", "price" => 16]
- ]
- ]
- ];
- ?>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Pizza Palooza</title>
- </head>
- <body>
- <br><center><div class='page_title'><h1>Pizza Palooza</h1></div></center><br>
- <form method ="post" action="cheese.php">
- <?php
- if(isset($_POST['next_button'])){
- if (isset($_POST['size'])) {
- $s = explode("_", $_POST['size']);
- $_0 = $s[0];
- $_1 = $s[1];
- // The above is purely so it's more readable
- echo "You selected a " . $pizza[$_0]['size'][$_1]['name'] . " " . $pizza[$_0]['type'] . " pizza for $" . $pizza[$_0]['size'][$_1]['price'];
- }
- else{
- header('Location:index.php');
- }
- }
- ?>
- <center>
- <table border="1" align='center'>
- <tbody>
- <?php // table column labels ?>
- <tr>
- <td style="text-align: center"><b><big>Image</big></b></td>
- <td style="text-align: center"><b><big>Crust Type</big></b></td>
- <td style="text-align: center"><b><big>Size</big></b></td>
- </tr>
- <?php
- // number of products is the count of $pizza
- $numb_products = count($pizza);
- $size_string = "";
- // loop printing info about pizzas in table
- for ($i = 0; $i < count($pizza); $i++) {
- if (empty($quantities)) {
- foreach ($pizza[$i]['size'] as $k => $s) {
- $size_post = $i . "_" . $k;
- $size_string .= "<input type=radio name='size' value='$size_post'";
- $size_string .= isset($_POST['size']) ? ($_POST['size'] == $i . "_" . $k ? " checked='checked'" : "") : "";
- $size_string .= ">" . $s['name'] . " ($" . $s['price'] . ")<br>";
- if (isset($errors['size'][$i])) {
- $size_string .= "<span style='font-style:italic;font-size:8px;color:red;'>{$errors['size'][$i]}</span>";
- }
- }
- // format table with printf
- printf('
- <tr>
- <td><img alt="Small" id="lightboxImage"
- style="width: 119px; height: 88px;"
- src="http://i.imgur.com/%s"
- height="300" width="300"></td>
- <td style="text-align: center;">%s</td>
- <td style="text-align: left;">' . $size_string . '</td>
- </tr>
- ', $pizza[$i]['image'], $pizza[$i]['type'], $pizza[$i]['price']);
- $size_string = "";
- }
- }
- // row with Purchase button
- ?>
- <tr><td colspan="5" style="text-align: right" border="none">
- <input type="button" name="back_button" value="Back" colspan="5" style="text-align: right" border="none" onclick="window.location = 'home.php'">
- <input type="submit" name="next_button" value="Next" onclick="window.location = 'cheese.php'">
- <?php // var_dump($_POST); ?>
- </td>
- </tr>
- </tbody>
- </table>
- </center> </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment