Food Ordering System using PHP and MySQL project is developed to emulate the online food ordering system. This Web Application is a simple implementation offering interface for customers and Administrators.
Customer Dashboard
The customer, to order food, must first register with the application by providing basic details. The customer has to set up a password to login and place the order. The Customer dashboard displays the categories/ cuisines being offered.
When logging in all food Items are displayed. On selection of a cuisine or category the dishes available in the category are displayed along with image of the dish and price. The Customer can click on Buy button provided with the food item to add it to his food box. Once he has selected all the items he wants to order he has to click on the place order link at top.
The presented page will display the items he has ordered. The quantities are 1 by default that can be updated before final order. When he presses the Place Order button, an Order ID is assigned and details of the order are stored in corresponding tables in database.
Admin Dashboard
When an admin logs on with her credentials, she is presented with dashboard to create new food categories and food items. A food Item can only be added against a food category. The administrator also has to save the category and food item images in the image folder. These are displayed along with the category or food item.
Activities Implemented in Food Ordering System using PHP and MySQL
- Customer Registration
- Administrator Registration
- Display of food items in customer dashboard
- Display of category wise food items in customer dashboard
- Selection of Food Items by Customer and Placing order
- Increasing or decreasing Quantity ordered
- Addition of new Food Category
- Addition of New food Items Under Food Categories
- Deletion of existing Food Category
- Deletion of a Food Item
- Modifying Name and Price of an existing Food Item
Platform Requirements
- PHP
- MySQL
- HTML
- AJAX
- Bootstrap CSS styles
Database name
foodorderdb (5 tables)
Database: `foodorderdb` -- -- -------------------------------------------------------- -- -- Table structure for table `menucategory_tbl` -- CREATE TABLE `menucategory_tbl` ( `Category` int(11) NOT NULL, `CatDesc` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `menuitems_tbl` -- CREATE TABLE `menuitems_tbl` ( `Category` int(11) NOT NULL, `MenuItemID` int(11) NOT NULL, `ItemName` varchar(30) NOT NULL, `Price` int(11) NOT NULL, `Discount` int(11) NOT NULL, `ItemImg` tinyblob NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `orderdetails_tbl` -- CREATE TABLE `orderdetails_tbl` ( `OrderID` int(11) NOT NULL, `ItemID` int(11) NOT NULL, `Quantity` int(11) NOT NULL, `Amount` float NOT NULL, `Discount` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `orders_tbl` -- CREATE TABLE `orders_tbl` ( `OrderID` int(11) NOT NULL, `OrderDate` date NOT NULL, `UserName` varchar(40) NOT NULL, `AmtPaid` float NOT NULL, `TotDiscount` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `users_tbl` -- CREATE TABLE `users_tbl` ( `UserName` varchar(60) NOT NULL, `Password` varchar(30) NOT NULL, `UserType` varchar(20) NOT NULL, `ContactNo` varchar(15) NOT NULL, `Email` varchar(50) NOT NULL, `DelAddress` varchar(100) NOT NULL, `City` varchar(40) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; COMMIT;
Interface and code
Homepage.html
<HTML> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <BODY> <div class="container" style="background-color:#E6D3F2;"> <div class="row" style="height: 5%; background-color:#D193F7; padding:40px;"> <div class="col-12"></div> </div> <div class="row" style="height: 5%;background-color:#480673; color:#ffffff;"> <div class="col-8"><h3>Gourmet Online Food Order</h3></div> <div class="col-2"><a href="HomePage.html">Log In to Order</a></div> <div class="col-2"><a href="adminLogin.html">Admin Login</a></div> </div> <div class="row" style="height: 20%; "> <div class="col-12"></div> </div> <span class="align-middle" > <div class="row"> <div class="col"> </div> <div class="colcol-lg-2" style="background-color:#ffffff; padding:40px; border-color:#230237; border-style: solid;border-width: thin;"> <form method="POST" action="verifyUser.php?utype=user"> <div class="form-group"> <label for="exampleInputName">User Name</label> <input type="string" class="form-control" id="username" aria-describedby="emailHelp" placeholder="Enter Your Name" name="username"> <small id="emailHelp" class="form-text text-muted">Enter a User Name that your will remember.</small> </div> <div class="form-group"> <label for="exampleInputPassword1">Password</label> <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" name="password"> <small id="passwordHelp" class="form-text text-muted">Keep it cryptic as possible.</small> </div> <button type="submit" class="btn btn-primary">Submit</button> <a class="btn btn-primary" data-toggle="collapse" href="NewUser.php" role="button" aria-expanded="false" aria-controls="collapseExample"> New User </a> </form> </div> <div class="col -md-auto"> </div> </div> </span> <div class="row" style="height: 20%; "> <div class="col-12"></div> </div> </div> </BODY> </HTML>
verifyUser.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); $un=$_POST["username"]; $pwd=$_POST["password"]; $utyp=$_GET["utype"]; $qry="select Password from Users_tbl where UserName='$un' and UserType='$utyp'"; $result=mysqli_query($con,$qry); while ($row=mysqli_fetch_array($result)) { if ($pwd==$row['Password']) { echo '<script> alert("Login Successful");</script>'; session_start(); $_SESSION['Uname']=$un; if ($utyp=='admin') header('refresh:0;url=adminLogin.php'); else header('refresh:0;url=Dashboard.php'); } else { echo '<script> alert("Incorrect UserName/User Type/Password");</script>'; header('refresh:0;url=HomePage.html'); } } ?>
NewUser.php
<HTML> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <BODY> <?php session_start(); $_SESSION['cart']=""; ?> <div class="container" style="background-color:#E6D3F2;"> <div class="row" style="height: 5%; background-color:#D193F7; padding:40px;"> <div class="col-12"></div> </div> <div class="row" style="height: 5%;background-color:#480673; color:#ffffff;"> <div class="col-8"><h3>Gourmet Online Food Order</h3></div> <div class="col-2"><a href="HomePage.html">Log In to Order</a></div> <div class="col-2"><a href="NewUser.html">Register as New User</a></div> </div> <div class="row" style="height: 10%; "> <div class="col-12"></div> </div> <span class="align-middle" > <div class="row"> <div class="col"> </div> <div class="colcol-lg-2" style="background-color:#ffffff; padding:40px; border-color:#230237; border-style: solid;border-width: thin;"> <form method="POST" Action="SaveUser.php"> <div class="form-group"> <label for="exampleInputName">User Name</label> <input type="string" class="form-control" id="username" name="username" aria-describedby="emailHelp" placeholder="Enter Your Name"> <small id="emailHelp" class="form-text text-muted">Enter a User Name that your will remember.</small> </div> <div class="form-group"> <label for="exampleInputPassword1">Password</label> <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" name="password"> <small id="passwordHelp" class="form-text text-muted">Keep it cryptic as possible.</small> </div> <div class="form-group"> <label for="exampleInputPassword1">Confirm Password</label> <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Confirm Password" name="cpassword"> </div> <div class="form-group"> <label for="exampleInputPhone">Contact Number</label> <input type="String" class="form-control" id="PhoneNo" placeholder=" Contact Number" name="phoneno"> </div> <div class="form-group"> <label for="exampleInputemail">EmailID</label> <input type="String" class="form-control" id="Email" placeholder=" Email ID" name="email"> </div> <div class="form-group"> <label for="exampleInputPhone">Delivery Address</label> <input type="String" class="form-control" id="DelAdd" placeholder=" Delivery Adderess" name="DeliAdd"> </div> <div class="form-group"> <label for="exampleInputemail">City</label> <input type="String" class="form-control" id="city" placeholder=" City" name="city"> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </div> <div class="col -md-auto"> </div> </div> </span> <div class="row" style="height: 20%; "> <div class="col-12"></div> </div> </div> </BODY> </HTML>
SaveUser.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); $un=$_POST["username"]; $pwd=$_POST["password"]; $phno=$_POST["phoneno"]; $eml=$_POST["email"]; $dadd=$_POST['DeliAdd']; $cty=$_POST['city']; $utype="user"; $qry="Insert into Users_tbl values ('$un','$pwd','$utype','$phno','$eml','$dadd','$cty')"; if (mysqli_query($con,$qry)==TRUE) { echo '<script> alert("Successful");</script>'; header('refresh:0;url=HomePage.html'); } else echo '<script> alert("Please try again");</script>'; ?>
adminlogin.php
<HTML> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#newCat").click(function(){ $("#contents").load("AddCategory.html"); }); $("#newItem").click(function(){ $("#contents").load("AddMenuItem.php"); }); $("#DelCat").click(function(){ $("#contents").load("DeleteCat.php"); }); $("#ModifyItem").click(function(){ $("#contents").load("ModifyItem.php"); }); }); </script> </head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <BODY> <div class="container" style="background-color:#E6D3F2;"> <div class="row" style="height: 5%; background-color:#D193F7; padding:40px;"> <div class="col-12"></div> </div> <div class="row" style="height: 5%;background-color:#480673; color:#ffffff;"> <div class="col-10"><h3>Gourmet Online Food Order</h3></div> <div class="col-2"><a href="logout.php">Log Out <?php session_start(); echo $_SESSION['Uname'];?></a></div> </div> <div class="row" style="margin:25px;height:90%;"> <div class="shadow-sm p-3 mb-5 bg-white rounded"> <div class="col-4" style="background-color:#ffffff; padding:40px; border-color:#230237; margin:20px;"></div> <ul class="list-group"> <div class="list-group-item list-group-item-info"><a id="newCat" href="#"> Create a Food Category</a></div> <div class="list-group-item list-group-item-info"><a id="newItem" href="#"> Add a Food Item</a></div> <div class="list-group-item list-group-item-info"><a id="DelCat" href="#"> Delete a Food Category</a></div> <div class="list-group-item list-group-item-info"><a id="ModifyItem" href="#"> Modify a Food Item</a></div> </div> <div class="col-8 shadow p-3 mb-5 bg-white rounded"> <div class="col-8" id="contents" style="background-color:#ffffff; padding:40px; border-color:#230237; margin:20px;"> </div> </div> </div> </div> </div> </BODY> </HTML>
dashboard.php
<HTML> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function() { $("button").click(function(){ var dataId = $(this).attr("id"); $.post("DisplayItems.php", {suggest: dataId}, function(result){ $("#contents").html(result); }); }); $("#po").click(function(){ $.post("PlaceOrder.php",{suggest: 3} , function(result){ $("#contents").html(result); }); }); }); </script> </head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <BODY> <div class="container" style="background-color:#E6D3F2;"> <div class="row" style="height: 5%; background-color:#D193F7; padding:40px;"> <div class="col-12"></div> </div> <div class="row" style="height: 5%;background-color:#480673; color:#ffffff;"> <div class="col-8"><h3>Gourmet Online Food Order</h3></div> <div class="col-2"><a href="#" id="po">Place Order</a></div> <div class="col-2"><a href="logout.php">Log Out <?php session_start(); echo $_SESSION['Uname'];?></a></div> </div> <div class="row" style="margin:25px;"> <div class="shadow-sm p-3 mb-5 bg-white rounded"> <div class="col-4" style="background-color:#ffffff; padding:40px; border-color:#230237; margin:20px;"></div> <?php $con=mysqli_connect("localhost","root","","foodorderdb"); $qry="select * from menucategory_tbl"; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { echo '<button id='.$rows['Category'].'><img src="image\\'.$rows['Category'].'.jpg" width="100px" height="100px"></button><br><blockquote class="blockquote text-center">'.$rows['CatDesc'].'</blockquote><br>'; } ?> </div> <div class="col-8 shadow p-3 mb-5 bg-white rounded"> <div class="col-8" id="contents" style="background-color:#ffffff; padding:40px; border-color:#230237; margin:20px;"> <div class="card-columns"> <?php $i=1; $qry='select * from menuitems_tbl'; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { echo '<div class="card" >'; echo '<img class="card-img-top" src="image\\'.$rows['MenuItemID'].'.jpg" height="120px" width="400px" alt="'.$rows['ItemName'].'" >'; echo '<div class="card-body">'; echo '<p class="card-text">'.$rows['ItemName'].'</p>'; echo '<p class="card-text">$'.$rows['Price'].'</p>'; $key=$rows["MenuItemID"]; echo "<a href='AddToCart.php?ItemID=$key'><button type='button' class='btn btn-primary'>Buy</button></a>"; echo '</div></div>'; $i++; } ?> </div> </div> </div> </div> </div> </BODY> </HTML>
DisplayItems.php
<HTML> <head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> </head> <body> <form > <div class="card-columns"> <?php $mc=$_POST['suggest']; $con=mysqli_connect("localhost","root","","foodorderdb"); $qry='select * from menuitems_tbl where Category='.$mc; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { echo '<div class="card" >'; echo '<img class="card-img-top" src="image\\'.$rows['MenuItemID'].'.jpg" height="100px" width="100px" alt="'.$rows['ItemName'].'">'; echo '<div class="card-body">'; echo '<p class="card-text">'.$rows['ItemName'].'</p>'; echo '<p class="card-text">Rs.'.$rows['Price'].'</p>'; $key=$rows["MenuItemID"]; echo "<a href='AddToCart.php?ItemID=$key'><button type='button' class='btn btn-primary'>Buy</button></a>"; echo '</div></div>'; } ?> </div> </form> </body> </HTML>
addToCart.php
<?php $dd=$_GET['ItemID']; session_start(); $_SESSION['cart']= $_SESSION['cart'].','.$dd; echo "<script>alert('".$dd." added');</script>"; echo $_SESSION['cart']; header('refresh:0;url=http://localhost:8088/foodorder/dashboard.php'); ?>
placeorder.php
<head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> </head> <form method="POST" action ="SaveBill.php"> <table border="1" align="center"> <tr> <th>Item ID</th> <th>Item Name</th> <th>Quantity</th> <th>Price</th> <th>Amount</th> </tr> <?php session_start(); $con=mysqli_connect("localhost","root","","foodorderdb"); $i=1; $tt=explode(",", substr($_SESSION['cart'],1)); foreach ($tt as $item) { $qry='select * from menuitems_tbl where MenuItemID='.$item; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { if ($i%2==0) { echo "<tr bgcolor='#ffccff'><td>"; } else { echo "<tr bgcolor='#ff99ff'><td>"; } $i++; echo $rows["MenuItemID"]; echo "</td>"; echo "<td>"; echo $rows["ItemName"]; echo "</td>"; echo "<td>"; echo '<input type="number" name="Quantity[]" value="1" size=5 style="text-align: center;"'; echo "</td>"; echo "<td>"; echo '<input type="number" name="Price[]" value="'. $rows["Price"].'" size=5 style="text-align: center;" disabled'; echo "</td>"; echo "<td>"; echo $rows["Price"]; echo "</td>"; echo "<td>"; } } ?> </table> <br><br> <center> <input type="submit" class="btn btn-outline-success" Value="Place Order"></button> </center> </form>
SaveBill.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); session_start(); $tt=explode(",", substr($_SESSION['cart'],1)); $qty=$_POST['Quantity']; $prc=$_POST['Price']; $nam= $_SESSION['Uname']; $billAmt=0; $qry="select max(OrderID) as maxid from Orders_tbl"; $oid=0; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { $oid=$rows[0]+1; } $cnt =0; for($cnt=0;$cnt<count($qty);$cnt++) { $qry="Insert into orderdetails_tbl values ($oid,".$tt[$cnt].",".$qty[$cnt].",".$qty[$cnt]*$prc[$cnt].",0)"; $billAmt=$billAmt+$qty[$cnt]*$prc[$cnt]; mysqli_query($con,$qry); } $qry="Insert into Orders_tbl values ($oid,'".date("Y/m/d")."','".$nam."',$billAmt,0)"; if (mysqli_query($con,$qry)==TRUE) { echo '<script> alert("Order Placed Successful");</script>'; header('refresh:0;url=dashboard.php'); } else { echo '<script> alert("Please try again");</script>'; header('refresh:0;url=dashboard.php'); } ?>
AddCategory.html
<HTML> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <BODY> <form method="POST" Action="SaveCategory.php"> <div class="form-group"> <label for="exampleInputName">Add New Food Category </label> <input type="string" class="form-control" id="CatDesc" name="CatDesc" placeholder="New Food Category"> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </BODY> </HTML>
SaveCategory.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); $cd=$_POST["CatDesc"]; $qry="select max(Category) as maxid from MenuCategory_tbl"; $jid=0; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { $jid=$rows[0]; } $qry="Insert into MenuCategory_tbl values ($jid+1,'$cd')"; if (mysqli_query($con,$qry)==TRUE) { echo '<script> alert("Category Added Successful");</script>'; header('refresh:0;url=adminLogin.php'); } else { echo '<script> alert("Please try again");</script>'; header('refresh:0;url=adminLogin.php'); } ?>
AddMenuItem.php
<HTML> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <BODY> <form method="POST" Action="SaveMenuItem.php"> <div class="form-row align-items-center"> <div class="col-auto my-1"> <label for="exampleInputName">Select Food category </label> <select class="custom-select mr-sm-2" name="Category"> <option selected>Choose...</option> <?php $con=mysqli_connect("localhost","root","","FoodOrderDB"); $qry="select Category, CatDesc from MenuCategory_tbl"; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { echo "<option value=".$rows['Category'].">".$rows['CatDesc']."</option>"; } ?> </select> </div> </div> <div class="form-group"> <label for="exampleInputName">Add Food Item </label> <input type="string" class="form-control" id="ItemName" name="ItemName" placeholder="New Food Item"> </div> <div class="form-group"> <label for="exampleInputName">Price</label> <input type="string" class="form-control" id="Price" name="Price" placeholder="Price"> </div> <div class="form-group"> <label for="exampleInputName">Discount</label> <input type="string" class="form-control" id="Discount" name="Discount" placeholder="Discount"> </div> <div class="form-group"> <label for="exampleInputName">Upload Item Image</label> <input type="file" name="fileToUpload" id="fileToUpload"> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </BODY> </HTML>
SaveMenuItem.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); $cat=$_POST["Category"]; $ItemName=$_POST['ItemName']; $Price=$_POST['Price']; $Dis=$_POST['Discount']; $itemimg = $_FILES['file']['fileToUpload']; $file = fopen($itemimg, 'r'); $file_contents = fread($file, filesize($itemimg)); fclose($file); $file_contents = addslashes($file_contents); $qry="select max(MenuItemID) as maxid from MenuItems_tbl "; $jd=0; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { $jd=$rows[0]; } $qry="Insert into MenuItems_tbl values ($cat,$jd+1,'$ItemName',$Price,$Dis,'$file_contents')"; if (mysqli_query($con,$qry)==TRUE) { echo '<script> alert("Menu Item Added Successful");</script>'; header('refresh:0;url=adminLogin.php'); } else { echo '<script> alert("Please try again");</script>'; header('refresh:0;url=adminLogin.php'); } ?>
deleteCategory.php
<HTML> <form method="POST" action="RemCat.php"> <div class="form-group"> <label for="exampleInputName">Catgory ID</label> <select name="abc" class="custom-select" id="inputGroupSelect03" > <option selected>Choose...</option> <?php $con=mysqli_connect("localhost","root","","foodorderdb"); $qry="select * from menucategory_tbl"; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { echo '<option value="'.$rows["Category"].'">'.$rows["CatDesc"].'</option>'; } ?> </select> </div> <button type="submit" class="btn btn-primary">Delete Category</button> </form> </HTML>
RemCat.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); $id=$_POST["abc"]; $qry="delete from menucategory_tbl where Category=$id"; if (mysqli_query($con,$qry)==true) { echo "<script> alert('Record Deleted');</script>"; echo "<script> window.location='adminLogin.php';</script>"; } ?>
ModifyItem.php
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <table class="table"> <thead> <tr> <th>ID</th> <th>Description</th> <th>Price</th> <th colspan=2 align="center">ACTION</th> </tr></thead><tbody> <?php $con=mysqli_connect("localhost","root","","foodorderdb"); $qry="select * from menuitems_tbl"; $recset=mysqli_query($con,$qry); while ($row=mysqli_fetch_array($recset)) { echo "<td>"; echo $row["MenuItemID"]; echo "</td>"; echo "<td>"; echo $row["ItemName"]; echo "</td>"; echo "<td>"; echo $row["Price"]; echo "</td>"; $ItemID=$row["MenuItemID"]; echo "<td>"; echo "<a href='delete.php?key=$ItemID'>DELETE</>"; echo "</td>"; echo "<TD><a href='modify.php?key=$ItemID'>MODIFY</>"; echo "</td></tr>"; } ?> </tbody> </table>
delete.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); $id=$_GET["key"]; $qry="delete from menuitems_tbl where MenuItemID=$id"; if (mysqli_query($con,$qry)==true) { echo "<script> alert('Record Deleted');</script>"; echo "<script> window.location='adminLogin.php';</script>"; } ?>
modify.php
<HTML> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <BODY> <div class="container" style="background-color:#E6D3F2;"> <div class="row" style="height: 5%; background-color:#D193F7; padding:40px;"> <div class="col-12"></div> </div> <div class="row" style="height: 5%;background-color:#480673; color:#ffffff;"> <div class="col-8"><h3>Gourmet Online Food Order</h3></div> <div class="col-2"><a href="HomePage.html">Log In to Order</a></div> <div class="col-2"><a href="adminLogin.html">Admin Login</a></div> </div> <div class="row" style="height: 20%; "> <div class="col-12"></div> </div> <span class="align-middle" > <div class="row"> <div class="col"> </div> <?php $con=mysqli_connect("localhost","root","","foodorderdb"); $id=$_GET["key"]; $qry="select * from menuitems_tbl where MenuItemID=$id"; $run=mysqli_query($con,$qry); while ($rows=mysqli_fetch_array($run)) { ?> <div class="colcol-lg-2" style="background-color:#ffffff; padding:40px; border-color:#230237; border-style: solid;border-width: thin;"> <form method="POST" action="UpdateItem.php"> <div class="form-group"> <label for="exampleInputName">Item ID</label> <input type="string" class="form-control" id="username" aria-describedby="emailHelp" name="ItemID" value=<?php echo $rows['MenuItemID'];?>> </div> <div class="form-group"> <label for="exampleInputPassword1">Item Neme</label> <input type="string" class="form-control" id="exampleInputPassword1" placeholder="Item Name" name="ItemName" value=<?php echo $rows['ItemName'];?>> </div> <div class="form-group"> <label for="exampleInputPassword1">Price</label> <input type="string" class="form-control" id="exampleInputPassword1" placeholder="Price" name="Price" value=<?php echo $rows['Price'];?>> </div> <button type="submit" class="btn btn-primary">Update Item</button> </form> </div> <?php }?> <div class="col -md-auto"> </div> </div> </span> <div class="row" style="height: 20%; "> <div class="col-12"></div> </div> </div> </BODY> </HTML>
UpdateItem.php
<?php $con=mysqli_connect("localhost","root","","foodorderdb"); $id=$_POST["ItemID"]; $in=$_POST["ItemName"]; $ip=$_POST["Price"]; $qry="update menuitems_tbl set ItemName='$in', Price=$ip where MenuItemID=$id"; if (mysqli_query($con,$qry)==true) { echo "<script> alert('Record updated');</script>"; echo "<script> window.location='adminLogin.php';</script>"; } ?>