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>


php html forms mysql

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Create Login and Registeration Form with PHP, HTML, CSS and MySQL

In this video we will create a Login and a Registeration form using PHP, HTML, CSS and MySQL. (User Login & Register Form in PHP and MySQL)

All You Need To Know About HTML Forms

This article provides an introduction to styling forms with CSS, including all the basics you might need to know for basic styling tasks.

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

Compare ScaleGrid MySQL vs. DigitalOcean Managed Databases - See which offers the best MySQL throughput, latency, and pricing on DigitalOcean across workloads.

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 and MySQL How to connect #HTML #login form to #PHP and #MySQL Part 2

In this video we will learn how to connect HTML login form with PHP and MySQL database for login operation. If email and password match then user will get message login successfully other wise he or she will get message Invalid user name or password.