Creating an insert statement for orders table html input form is not getting handled

Creating an insert statement for orders table html input form is not getting handled

I am trying to create an order form where personell of the restaurant can manually take orders from a customer. and later see what order they have made.

I am trying to create an order form where personell of the restaurant can manually take orders from a customer. and later see what order they have made.

my statement keeps refusing to insert this data into the database. I would like to know what i am doing wrong here.,

This is my database:

MenuItem: 
    MenuItemID  int(11)         
    ItemName    varchar(255)        
    ItemPrice   double

orders: OrderID int(11)
MenuItemID int(11)
ReceiptID int(11)
Res_Datum date
Tafel_Id int(11)
Res_ID int(11)

receipt: ReceiptID int(11)
ReceiptPrice double

reserveringen:
Reservering_Id int(11)
Tafel_Id int(11)
VoorNaam varchar(255)
AchterNaam varchar(255)
TelefoonNummer varchar(255)
Email varchar(255)
Res_Datum date

tafels: Tafel_Id int(11)
tafel_Nummer int(11)
Aantal_Personen int(11)

Orders are shown by orders.Tafel_Id, orders.ReceiptID, orders.MenuItemID, orders.ReceiptID, orders.Res_Datum

$sql = "SELECT O.Res_Datum, O.Res_ID, O.Tafel_Id,O.ReceiptID, SUM(MI.ItemPrice) AS TotalReceiptPrice
FROM Orders AS O INNER JOIN MenuItem AS MI ON O.MenuItemID = MI.MenuItemID
GROUP BY O.Res_Datum, O.Res_ID, O.Tafel_Id ";
$result = $conn->query($sql);

I am trying to insert this data into my database through this form, but I cannot figure out why it is not working.

Maak_bestelling.php :

<?php

$con = mysqli_connect('localhost','root','');

if(!$con) { echo 'Not connected with server'; }

if(!mysqli_select_db ($con,'restaurant')) { echo 'Database Not selected'; }

$tablenumber = $_POST['tafelnummer']; $receiptid = $_POST['receiptid']; $menu_item = $_POST['menu_item']; $date = $_POST['date'];

$sql = "INSERT INTO Orders (orders.Tafel_Id, orders.ReceiptID, orders.MenuItemID, orders.ReceiptID, orders.Res_Datum ) VALUES ('$tablenumber', '$receiptid', '$menu_item', '$date')";

if(!mysqli_query($con,$sql)){ echo 'insert did not work'; }else { echo 'Order created successfully'; }

header("refresh:1; url=bestelling.php");

bestelling.php:

<form action="/restaurant/maak_bestelling.php" method="POST">
  <h2>Enter Order</h2>

Table Number:<br> <input type="text" name="tafelnummer" value=""><br><br> Receipt Id:<br> <input type="text" name="receiptid" value=""><br><br> Menu_Item:<br> <input type="text" name="menu_item" value=""><br><br> Date: <br> <input type="date" name="date" value=""><br><br>

<input type="submit" value="Submit"> </form>

<h2>Pending Orders:</h2> <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "restaurant";

// Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }

//$sql = "SELECT O.Res_Datum,O.Res_ID, O.Tafel_Id, SUM(MI.ItemPrice) AS TotalReceiptPrice FROM Orders AS O INNER JOIN MenuItem AS MI ON O.MenuItemID = MI.MenuItemID "; $sql = "SELECT O.Res_Datum, O.Res_ID, O.Tafel_Id,O.ReceiptID, SUM(MI.ItemPrice) AS TotalReceiptPrice FROM Orders AS O INNER JOIN MenuItem AS MI ON O.MenuItemID = MI.MenuItemID GROUP BY O.Res_Datum, O.Res_ID, O.Tafel_Id "; $result = $conn->query($sql);

if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "Res_datum: ". $row["Res_Datum"]. " ReservationID : " . $row["Res_ID"]. " - Table_Number: " . $row["Tafel_Id"]. " Total Order Price: " . $row["TotalReceiptPrice"]." ". "<br>"; } } else { echo "0 results"; }

mysqli_close($conn); ?>

</div>


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Build a Register & Login Form using PHP, HTML, CSS, Bootstrap and MySQL

In this tutorial you will learn and build a Responsive PHP Registration & Login Form using PHP, HTML, CSS, Bootstrap and MySQL

PhP MySQL Projects

Simpliv LLC, a platform for learning and teaching online courses. We basically focus on online learning which helps to learn business concepts, software technology to develop personal and professional goals through video library by recognized industry experts and trainers.

Create Registration form with MySQL and PHP

In membership-based website registration and login page is common.User needs to create a new account and login to the website to access services and manage its account.In this tutorial, I show how you can create a signup page with MySQL and PHP.