Advertisement
Guest User

Untitled

a guest
Apr 30th, 2018
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.31 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "root";
  5. $dbname = "Restaurant";
  6.  
  7. // Create connection
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9. // Check connection
  10. if (!$conn) {
  11. die("Connection failed: " . mysqli_connect_error());
  12. }
  13. ?>
  14.  
  15. <!DOCTYPE html>
  16. <html>
  17.  
  18. <head>
  19. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  20. <title></title>
  21. </head>
  22.  
  23. <body>
  24. <br>
  25.  
  26. <form name="" action="">
  27. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  28. <title>Stefan</title>
  29. <h1> Stefan's Italian Restaurant </h1>
  30. <br <br> Contact Information
  31. <br>
  32. <p>
  33.  
  34. <input name="a" placeholder="First Name" type="text">
  35. <input name="Middle Initial" placeholder="Middle Initial" maxlength="1" type="text">
  36. <input name="Last Name" placeholder="Last Name" type="text">
  37. <input name="Email" placeholder="Email Address" type="text">
  38. <input name="Phone Number" placeholder="Phone Number" type="tel">
  39. </p>
  40. <p>Shipping Address</p>
  41. <p>
  42. <input name="Address" placeholder="Street" type="text">
  43. <input name="City" placeholder="City" type="text">
  44. <input name="State" placeholder="State" type="text">
  45. <input name="Zip" placeholder="Zip Code" maxlength="5" type="text">
  46. </p>
  47. <p> Customer Satisfaction</p>
  48. <p>
  49. <textarea name="text" placeholder="How can we improve?"></textarea>&nbsp;
  50. </p>
  51. <input name="Reset" value="Reset Form" type="reset">
  52. <br>
  53. <br>
  54. <?php
  55.  
  56. //Start the session
  57. session_start();
  58.  
  59. //Create 'cart' if it doesn't already exist
  60. if (!isset($_SESSION['SHOPPING_CART'])){ $_SESSION['SHOPPING_CART'] = array(); }
  61.  
  62. //Add an item only if we have the threee required pices of information: name, price, qty
  63. if (isset($_GET['add']) && isset($_GET['price']) && isset($_GET['qty'])){
  64. //Adding an Item
  65. //Store it in a Array
  66. $ITEM = array(
  67. //Item name
  68. 'name' => $_GET['add'],
  69. //Item Price
  70. 'price' => $_GET['price'],
  71. //Qty wanted of item
  72. 'qty' => $_GET['qty']
  73. );
  74.  
  75. //Add this item to the shopping cart
  76. $_SESSION['SHOPPING_CART'][] = $ITEM;
  77. //Clear the URL variables
  78. header('Location: ' . $_SERVER['PHP_SELF']);
  79. }
  80. //Allowing the modification of individual items no longer keeps this a simple shopping cart.
  81. //We only support emptying and removing
  82. else if (isset($_GET['remove'])){
  83. //Remove the item from the cart
  84. unset($_SESSION['SHOPPING_CART'][$_GET['remove']]);
  85. //Re-organize the cart
  86. //array_unshift ($_SESSION['SHOPPING_CART'], array_shift ($_SESSION['SHOPPING_CART']));
  87. //Clear the URL variables
  88. header('Location: ' . $_SERVER['PHP_SELF']);
  89.  
  90. }
  91. else if (isset($_GET['empty'])){
  92. //Clear Cart by destroying all the data in the session
  93. session_destroy();
  94. //Clear the URL variables
  95. header('Location: ' . $_SERVER['PHP_SELF']);
  96.  
  97. }
  98. else if (isset($_POST['update'])) {
  99. //Updates Qty for all items
  100. foreach ($_POST['items_qty'] as $itemID => $qty) {
  101. //If the Qty is "0" remove it from the cart
  102. if ($qty == 0) {
  103. //Remove it from the cart
  104. unset($_SESSION['SHOPPING_CART'][$itemID]);
  105. }
  106. else if($qty >= 1) {
  107. //Update to the new Qty
  108. $_SESSION['SHOPPING_CART'][$itemID]['qty'] = $qty;
  109. }
  110. }
  111. //Clear the POST variables
  112. header('Location: ' . $_SERVER['PHP_SELF']);
  113. }
  114. ?>
  115.  
  116. <form action="" method="post" name="shoppingcart">
  117. <a?php
  118. ob_start();
  119. ?>
  120.  
  121. Product # &nbsp;&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;&nbsp; Name &nbsp;&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;&nbsp; Price
  122.  
  123. <?php
  124.  
  125. //Print all the items in the shopping cart
  126. $totalAll = 0;
  127. foreach ($_SESSION['SHOPPING_CART'] as $itemNumber => $item) {
  128.  
  129. $totalAll = $totalAll + ($item['qty']*$item['price']);
  130.  
  131. ?>
  132. <tr id="item<?php echo $itemNumber; ?>">
  133. <td height="41"><a href="?remove=<?php echo $itemNumber; ?>">Remove Item</a></td>
  134. <td>
  135. <?php echo $item['name']; ?>
  136. </td>
  137. <td>£
  138. <?php echo $item['price']; ?>
  139. </td>
  140. <td>
  141. <input name="items_qty[<?php echo $itemNumber; ?>]" type="text" id="item<?php echo $itemNumber; ?>_qty" value="<?php echo $item['qty']; ?>" size="2" maxlength="3" />
  142. </td>
  143. <td>£
  144. <?php echo $item['qty'] * $item['price']; ?>
  145. </td>
  146. <td>£
  147. <?php echo $totalAll;?>
  148. </td>
  149. </tr>
  150. <?php
  151.  
  152. }
  153. ?>
  154.  
  155. </table>
  156. <?php $_SESSION['SHOPPING_CART_HTML'] = ob_get_flush(); ?>
  157. <p align="left">
  158. <label>
  159.  
  160. <form name="form1" action="" method="post">
  161. <select>
  162.  
  163. <?php
  164. $sql = "SELECT * FROM food";
  165.  
  166. $result = mysqli_query($conn, $sql);
  167.  
  168. if (mysqli_num_rows($result) > 0) {
  169. // output data of each row
  170. while($row = mysqli_fetch_assoc($result))
  171. { ?>
  172.  
  173. <option>
  174. <?php echo ' Product #' . $row['Prod_Number'] . ' | ' . $row['Name'] . ' | $' . $row['Price'];
  175. echo "</br>" ?>
  176. </option>
  177. echo " ""<h2>PHP is Fun!</h2>" " ";
  178. <?php
  179. }
  180. } else {
  181. echo "0 results";
  182. }
  183.  
  184. // mysqli_close($conn);
  185. ?>
  186.  
  187. <input name="OrderNumber" min="1" max="100" type="number">&nbsp;
  188.  
  189. </select>
  190. </form>
  191.  
  192. <form name="form1" action="" method="post">
  193. <select>
  194.  
  195. <?php
  196. $sql = "SELECT * FROM food";
  197.  
  198. $result = mysqli_query($conn, $sql);
  199.  
  200. if (mysqli_num_rows($result) > 0) {
  201. // output data of each row
  202. while($row = mysqli_fetch_assoc($result))
  203. { ?>
  204. <option>
  205. <?php echo ' Product #' . $row['Prod_Number'] . ' | ' . $row['Name'] . ' | $' . $row['Price'];
  206. echo "</br>" ?>
  207. </option>
  208. <?php
  209. }
  210. } else {
  211. echo "0 results";
  212. }
  213.  
  214. // mysqli_close($conn);
  215. ?>
  216.  
  217. <input name="OrderNumber" min="1" max="100" type="number">&nbsp;
  218. <br>
  219.  
  220. <form name="form1" action="" method="post">
  221. <select>
  222.  
  223. <?php
  224. $sql = "SELECT * FROM food";
  225.  
  226. $result = mysqli_query($conn, $sql);
  227.  
  228. if (mysqli_num_rows($result) > 0) {
  229. // output data of each row
  230. while($row = mysqli_fetch_assoc($result))
  231. { ?>
  232. <option>
  233. <?php echo ' Product #' . $row['Prod_Number'] . ' | ' . $row['Name'] . ' | $' . $row['Price'];
  234. echo "</br>" ?>
  235. </option>
  236. <?php
  237. }
  238. } else {
  239. echo "0 results";
  240. }
  241.  
  242. // mysqli_close($conn);
  243. ?>
  244.  
  245. <input name="OrderNumber" min="1" max="100" type="number">&nbsp;
  246. <br>
  247.  
  248. <p><a href="../products.php">Keep Shopping</a> - <a href="?empty">Empty Cart</a>
  249. <br />
  250. <br />
  251.  
  252. <input type="submit" name="update" id="update" value="Update Cart" />
  253. <br />
  254. <br />
  255. </label>
  256.  
  257. </form>
  258.  
  259. <p>
  260. <script type="text/javascript">
  261. function displayForm(c) {
  262. if (c.value == "1") {
  263.  
  264. document.getElementById("ccformContainer").style.visibility = 'visible';
  265. document.getElementById("paypalformContainer").style.visibility = 'hidden';
  266. document.getElementById("checkformContainer").style.visibility = 'hidden';
  267. } else if (c.value == "2") {
  268. document.getElementById("ccformContainer").style.visibility = 'hidden';
  269. document.getElementById("paypalformContainer").style.visibility = 'visible';
  270. document.getElementById("checkformContainer").style.visibility = 'hidden';
  271.  
  272. } else if (c.value == "3") {
  273. document.getElementById("checkformContainer").style.visibility = 'visible';
  274. document.getElementById("ccformContainer").style.visibility = 'hidden';
  275. document.getElementById("paypalformContainer").style.visibility = 'hidden';
  276.  
  277. } else {}
  278. }
  279. </script>
  280. </p>
  281. <input value="1" name="formselector" onclick="displayForm(this)" type="radio">Via Credit Card
  282. <br>
  283. <input value="2" name="formselector" onclick="displayForm(this)" type="radio">Via Paypal
  284. <br>
  285. <input value="3" name="formselector" onclick="displayForm(this)" type="radio">Via Check
  286. </form>
  287. <div style="visibility:hidden; position:relative" id="ccformContainer">
  288. <form id="ccform">
  289. <label>Enter your credit card details :</label>
  290. <br>
  291. <br>
  292. <dd>
  293. <p>Credit Card Name :
  294. <input id="ccname" name="ccname" value="$ccname" type="text">
  295. </p>
  296. <p>Credit Card Type :
  297. <select name="cctype" required="">
  298. <option value="Visa">Visa</option>
  299. <option value="Mastercard">Mastercard</option>
  300. <option value="American Express">American Express</option>
  301. <option value="Discover">Discover</option>
  302. <option value="Diners Club">Diners Club</option>
  303. <option value="Maestro">Maestro</option>
  304. <option value="Verified By Visa">Verified By Visa</option>
  305. <option value="Visa Electron">Visa Electron</option>
  306. </select>
  307. </p>
  308. <p>Credit Card Number :
  309. <input minlength="16" id="ccnumber" name="ccnumber" value="$ccnumber" type="text">
  310. </p>
  311. <p>Credit Expiry Date : Month :
  312. <select name="ccexpdatemonth" required="">
  313. <option value="1">1</option>
  314. <option value="2">2</option>
  315. <option value="3">3</option>
  316. <option value="4">4</option>
  317. <option value="5">5</option>
  318. <option value="6">6</option>
  319. <option value="7">7</option>
  320. <option value="8">8</option>
  321. <option value="9">9</option>
  322. <option value="10">10</option>
  323. <option value="11">11</option>
  324. <option value="12">12</option>
  325. </select>
  326. <span>Year :
  327. <select name="ccexpdateyear" required="">
  328. <option value="2009">2009</option>
  329. <option value="2010">2010</option>
  330. <option value="2011">2011</option>
  331. <option value="2012">2012</option>
  332. </select>
  333. </span> </p>
  334. <p>Credit Card CVC :
  335. <input minlength="3" id="cccvc" name="cccvc" value="$cccvc" type="text">
  336. <input name="Submit" value="Complete Payment" type="submit">
  337.  
  338. </p>
  339. </dd>
  340. </form>
  341. </div>
  342. <div style="visibility:hidden;position:relative;top:-110px;margin-top:-110px" id="paypalformContainer">
  343. <form id="paypalform">
  344. <label>Enter your Paypal Details</label>
  345. <br>
  346. <br>
  347. <dd>Paypal Address :
  348. <input id="paypal" name="paypal" value="$paypal" type="text">
  349. <input name="Submit" value="Complete Payment" type="submit">
  350.  
  351. </dd>
  352. </form>
  353. </div>
  354. <div style="visibility:hidden;position:relative;top:-90px;margin-top:-90px" id="checkformContainer">
  355. <form id="checkform">
  356. <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>
  357. <br>
  358.  
  359. </form>
  360. <p>Payment Information </p>
  361. <input name="Submit" value="Complete Payment" type="submit">
  362. </div>
  363. </body>
  364. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement