Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "root";
- $dbname = "Restaurant";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title></title>
- </head>
- <body>
- <br>
- <form name="" action="">
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title>Stefan</title>
- <h1> Stefan's Italian Restaurant </h1>
- <br <br> Contact Information
- <br>
- <p>
- <input name="a" placeholder="First Name" type="text">
- <input name="Middle Initial" placeholder="Middle Initial" maxlength="1" type="text">
- <input name="Last Name" placeholder="Last Name" type="text">
- <input name="Email" placeholder="Email Address" type="text">
- <input name="Phone Number" placeholder="Phone Number" type="tel">
- </p>
- <p>Shipping Address</p>
- <p>
- <input name="Address" placeholder="Street" type="text">
- <input name="City" placeholder="City" type="text">
- <input name="State" placeholder="State" type="text">
- <input name="Zip" placeholder="Zip Code" maxlength="5" type="text">
- </p>
- <p> Customer Satisfaction</p>
- <p>
- <textarea name="text" placeholder="How can we improve?"></textarea>
- </p>
- <input name="Reset" value="Reset Form" type="reset">
- <br>
- <br>
- <?php
- //Start the session
- session_start();
- //Create 'cart' if it doesn't already exist
- if (!isset($_SESSION['SHOPPING_CART'])){ $_SESSION['SHOPPING_CART'] = array(); }
- //Add an item only if we have the threee required pices of information: name, price, qty
- if (isset($_GET['add']) && isset($_GET['price']) && isset($_GET['qty'])){
- //Adding an Item
- //Store it in a Array
- $ITEM = array(
- //Item name
- 'name' => $_GET['add'],
- //Item Price
- 'price' => $_GET['price'],
- //Qty wanted of item
- 'qty' => $_GET['qty']
- );
- //Add this item to the shopping cart
- $_SESSION['SHOPPING_CART'][] = $ITEM;
- //Clear the URL variables
- header('Location: ' . $_SERVER['PHP_SELF']);
- }
- //Allowing the modification of individual items no longer keeps this a simple shopping cart.
- //We only support emptying and removing
- else if (isset($_GET['remove'])){
- //Remove the item from the cart
- unset($_SESSION['SHOPPING_CART'][$_GET['remove']]);
- //Re-organize the cart
- //array_unshift ($_SESSION['SHOPPING_CART'], array_shift ($_SESSION['SHOPPING_CART']));
- //Clear the URL variables
- header('Location: ' . $_SERVER['PHP_SELF']);
- }
- else if (isset($_GET['empty'])){
- //Clear Cart by destroying all the data in the session
- session_destroy();
- //Clear the URL variables
- header('Location: ' . $_SERVER['PHP_SELF']);
- }
- else if (isset($_POST['update'])) {
- //Updates Qty for all items
- foreach ($_POST['items_qty'] as $itemID => $qty) {
- //If the Qty is "0" remove it from the cart
- if ($qty == 0) {
- //Remove it from the cart
- unset($_SESSION['SHOPPING_CART'][$itemID]);
- }
- else if($qty >= 1) {
- //Update to the new Qty
- $_SESSION['SHOPPING_CART'][$itemID]['qty'] = $qty;
- }
- }
- //Clear the POST variables
- header('Location: ' . $_SERVER['PHP_SELF']);
- }
- ?>
- <form action="" method="post" name="shoppingcart">
- <a?php
- ob_start();
- ?>
- Product # | Name | Price
- <?php
- //Print all the items in the shopping cart
- $totalAll = 0;
- foreach ($_SESSION['SHOPPING_CART'] as $itemNumber => $item) {
- $totalAll = $totalAll + ($item['qty']*$item['price']);
- ?>
- <tr id="item<?php echo $itemNumber; ?>">
- <td height="41"><a href="?remove=<?php echo $itemNumber; ?>">Remove Item</a></td>
- <td>
- <?php echo $item['name']; ?>
- </td>
- <td>£
- <?php echo $item['price']; ?>
- </td>
- <td>
- <input name="items_qty[<?php echo $itemNumber; ?>]" type="text" id="item<?php echo $itemNumber; ?>_qty" value="<?php echo $item['qty']; ?>" size="2" maxlength="3" />
- </td>
- <td>£
- <?php echo $item['qty'] * $item['price']; ?>
- </td>
- <td>£
- <?php echo $totalAll;?>
- </td>
- </tr>
- <?php
- }
- ?>
- </table>
- <?php $_SESSION['SHOPPING_CART_HTML'] = ob_get_flush(); ?>
- <p align="left">
- <label>
- <form name="form1" action="" method="post">
- <select>
- <?php
- $sql = "SELECT * FROM food";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result))
- { ?>
- <option>
- <?php echo ' Product #' . $row['Prod_Number'] . ' | ' . $row['Name'] . ' | $' . $row['Price'];
- echo "</br>" ?>
- </option>
- echo " ""<h2>PHP is Fun!</h2>" " ";
- <?php
- }
- } else {
- echo "0 results";
- }
- // mysqli_close($conn);
- ?>
- <input name="OrderNumber" min="1" max="100" type="number">
- </select>
- </form>
- <form name="form1" action="" method="post">
- <select>
- <?php
- $sql = "SELECT * FROM food";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result))
- { ?>
- <option>
- <?php echo ' Product #' . $row['Prod_Number'] . ' | ' . $row['Name'] . ' | $' . $row['Price'];
- echo "</br>" ?>
- </option>
- <?php
- }
- } else {
- echo "0 results";
- }
- // mysqli_close($conn);
- ?>
- <input name="OrderNumber" min="1" max="100" type="number">
- <br>
- <form name="form1" action="" method="post">
- <select>
- <?php
- $sql = "SELECT * FROM food";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result))
- { ?>
- <option>
- <?php echo ' Product #' . $row['Prod_Number'] . ' | ' . $row['Name'] . ' | $' . $row['Price'];
- echo "</br>" ?>
- </option>
- <?php
- }
- } else {
- echo "0 results";
- }
- // mysqli_close($conn);
- ?>
- <input name="OrderNumber" min="1" max="100" type="number">
- <br>
- <p><a href="../products.php">Keep Shopping</a> - <a href="?empty">Empty Cart</a>
- <br />
- <br />
- <input type="submit" name="update" id="update" value="Update Cart" />
- <br />
- <br />
- </label>
- </form>
- <p>
- <script type="text/javascript">
- function displayForm(c) {
- if (c.value == "1") {
- document.getElementById("ccformContainer").style.visibility = 'visible';
- document.getElementById("paypalformContainer").style.visibility = 'hidden';
- document.getElementById("checkformContainer").style.visibility = 'hidden';
- } else if (c.value == "2") {
- document.getElementById("ccformContainer").style.visibility = 'hidden';
- document.getElementById("paypalformContainer").style.visibility = 'visible';
- document.getElementById("checkformContainer").style.visibility = 'hidden';
- } else if (c.value == "3") {
- document.getElementById("checkformContainer").style.visibility = 'visible';
- document.getElementById("ccformContainer").style.visibility = 'hidden';
- document.getElementById("paypalformContainer").style.visibility = 'hidden';
- } else {}
- }
- </script>
- </p>
- <input value="1" name="formselector" onclick="displayForm(this)" type="radio">Via Credit Card
- <br>
- <input value="2" name="formselector" onclick="displayForm(this)" type="radio">Via Paypal
- <br>
- <input value="3" name="formselector" onclick="displayForm(this)" type="radio">Via Check
- </form>
- <div style="visibility:hidden; position:relative" id="ccformContainer">
- <form id="ccform">
- <label>Enter your credit card details :</label>
- <br>
- <br>
- <dd>
- <p>Credit Card Name :
- <input id="ccname" name="ccname" value="$ccname" type="text">
- </p>
- <p>Credit Card Type :
- <select name="cctype" required="">
- <option value="Visa">Visa</option>
- <option value="Mastercard">Mastercard</option>
- <option value="American Express">American Express</option>
- <option value="Discover">Discover</option>
- <option value="Diners Club">Diners Club</option>
- <option value="Maestro">Maestro</option>
- <option value="Verified By Visa">Verified By Visa</option>
- <option value="Visa Electron">Visa Electron</option>
- </select>
- </p>
- <p>Credit Card Number :
- <input minlength="16" id="ccnumber" name="ccnumber" value="$ccnumber" type="text">
- </p>
- <p>Credit Expiry Date : Month :
- <select name="ccexpdatemonth" required="">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- </select>
- <span>Year :
- <select name="ccexpdateyear" required="">
- <option value="2009">2009</option>
- <option value="2010">2010</option>
- <option value="2011">2011</option>
- <option value="2012">2012</option>
- </select>
- </span> </p>
- <p>Credit Card CVC :
- <input minlength="3" id="cccvc" name="cccvc" value="$cccvc" type="text">
- <input name="Submit" value="Complete Payment" type="submit">
- </p>
- </dd>
- </form>
- </div>
- <div style="visibility:hidden;position:relative;top:-110px;margin-top:-110px" id="paypalformContainer">
- <form id="paypalform">
- <label>Enter your Paypal Details</label>
- <br>
- <br>
- <dd>Paypal Address :
- <input id="paypal" name="paypal" value="$paypal" type="text">
- <input name="Submit" value="Complete Payment" type="submit">
- </dd>
- </form>
- </div>
- <div style="visibility:hidden;position:relative;top:-90px;margin-top:-90px" id="checkformContainer">
- <form id="checkform">
- <label> <p> Please mail all checks issue all checks to Stefan's Pizzaria. Checks can be mailed to food 300 Pompton Road, Wayne NJ 07470 </label>
- <br>
- </form>
- <p>Payment Information </p>
- <input name="Submit" value="Complete Payment" type="submit">
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement