Sean Robertson

Sean Robertson

1548258379

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.

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

What is GEEK

Buddha Community

In your insert statement you have repeated the ReceipID, so you have to remove it like this:

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

Sean Robertson

Sean Robertson

1548258379

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.

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

Hertha  Mayer

Hertha Mayer

1595425063

All You Need To Know About HTML Forms

Forms are ways of providing information, and so is an HTML form, but rather on a web page, using a browser. As much as a normal paper form contains fields to fill in your details, and after that, you can submit to someone in charge, so HTML forms also provide inputs fields, which serve as fields that allow you to fill in your data and submit to the server for some processing and back to the person-in-charge (the developer).

The above things are however not new to a web developer, as millions of forms are being filled on websites daily. But whether you are new to the game or a professional. This tutorial tells all that you need to know about HTML Forms, including HTML form action, form methods, HTML form encoding types, and form processing.

Let’s dive into the details!

HTML Form Action

HTML Form actions point to where the form should be submitted. This is done with the action attribute. The value of the action attribute is typically a URL to an external or internal page.

Example

<form action="https://example.com" method="GET"> ... </form>

HTML Form Methods

Form methods tell the browser to send the users’ data, and in other ways tells the server how to process the provided information by your user. This is possible in HTML form by using the method attribute. This attribute can either be "GET" or "POST" depending on the purpose of the form.

The GET Method

The GET method tells the browser to include all the form data in the URL after submitting. Each piece of data appears by sending the URL in the action attribute, followed by ? followed by key=value. This method should be used for processing less-sensitive data, such as name search or getting content per user (/?username=Bob), and should not be used for processing sensitive information such as passwords. We will discuss a method suitable for processing sensitive data in the next section. Let’s use a live example.

Example: GET Method

<form method="GET" action="search.php">  
<input type="search" name="key" /> <input type="submit" value="Search" name="submit" /> </form>   

When this form is submitted, the processed URL will result in something like /search.php?key=hello&submit=Search. You can see that all users’ information is displayed on the URL in the format of key=value. The example stands as a good reason for you to know why it is bad and not advisable to include sensitive information on a GET form. Let’s look into a bad way of using GET method.

Note

The key is the value provided in the attribute of each form field, therefore the name attribute is important in HTML form processing.

Wrong Example: POST Method

Take a look at the example above, so for example, assuming user enters the username ola and password and clicks on login, this will result to a URL: /login.php?username=ola&password=password&submit=Login, revealing sensitive information on the browser’s URL, this can be used by hackers to get vital information, and get access to personal accounts.

#html-fundamentals #html #html5 #tutorial #html-forms #guide-to-html-forms #latest-tech-stories #php

Ava Watson

Ava Watson

1595318322

Know Everything About HTML With HTML Experts

HTML stands for a hypertext markup language. For the designs to be displayed in web browser HTML is the markup language. Technologies like Cascading style sheets (CSS) and scripting languages such as JavaScript assist HTML. With the help of HTML websites and the web, designs are created. Html has a wide range of academic applications. HTML has a series of elements. HTML helps to display web content. Its elements tell the web how to display the contents.

The document component of HTML is known as an HTML element. HTML element helps in displaying the web pages. An HTML document is a mixture of text nodes and HTML elements.

Basics of HTML are-

The simple fundamental components oh HTML is

  1. Head- the setup information for the program and web pages is carried in the head
  2. Body- the actual substance that is to be shown on the web page is carried in the body
  3. HTML- information starts and ends with and labels.
  4. Comments- come up in between

Html versions timeline

  1. HTML was created in 1990. Html is a program that is updated regularly. the timeline for the HTML versions is
  2. HTML 2- November, 1995
  3. HTML 3- January, 1997
  4. HTML 4- December, 1997; April, 1998; December, 1999; May, 2000
  5. HTML 5- October, 2014; November, 2016; December, 2017

HTML draft version timelines are

  1. October 1991
  2. June 1992
  3. November 1992
  4. June 1993
  5. November 1993
  6. November 1994
  7. April 1995
  8. January 2008
  9. HTML 5-
    2011, last call
    2012 candidate recommendation
    2014 proposed recommendation and recommendation

HTML helps in creating web pages. In web pages, there are texts, pictures, colouring schemes, tables, and a variety of other things. HTML allows all these on a web page.
There are a lot of attributes in HTML. It may get difficult to memorize these attributes. HTML is a tricky concept. Sometimes it gets difficult to find a single mistake that doesn’t let the web page function properly.

Many minor things are to be kept in mind in HTML. To complete an HTML assignment, it is always advisable to seek help from online experts. These experts are well trained and acknowledged with the subject. They provide quality content within the prescribed deadline. With several positive reviews, the online expert help for HTML assignment is highly recommended.

#html assignment help #html assignment writing help #online html assignment writing help #html assignment help service online #what is html #about html

Fynzo Survey

Fynzo Survey

1621064209

Form Builder | Create Online Forms Free | Fynzo Survey

Create professional forms for registrations, collecting contact details, or simply receiving feedback. Fynzo’s form builder is cost effective, easy to use, 100% secure with amazing personalization features and can integrate with all your favourite tools.

For more info visit: https://www.fynzo.com/survey/lp/form-builder

#form builder #online form builder #create online forms free #create professional forms

Alisha  Larkin

Alisha Larkin

1617789060

HTML Tutorial For Beginners

The prospect of learning HTML can seem confusing at first: where to begin, what to learn, the best ways to learn — it can be difficult to get started. In this article, we’ll explore the best ways for learning HTML to assist you on your programming journey.

What is HTML?

Hypertext Markup Language (HTML) is the standard markup language for documents meant to be displayed in a web browser. Along with Cascading Style Sheets (CSS) and JavaScript, HTML completes the trio of essential tools used in creating modern web documents.

HTML provides the structure of a webpage, from the header and footer sections to paragraphs of text, videos, and images. CSS allows you to set the visual properties of different HTML elements, like changing colors, setting the order of blocks on the screen, and defining which elements to display. JavaScript automates changes to HTML and CSS, for example, making the font larger in a paragraph when a user clicks a button on the page.

#html #html-css #html-fundamentals #learning-html #html-css-basics #html-templates