-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneworder.php
42 lines (31 loc) · 1.06 KB
/
neworder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
//including the database connection file
include_once("connection.php");
if(isset($_POST['Submit'])) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$duedate = $_POST['duedate'];
$details = $_POST['detail'];
// checking empty fields
if(empty($name) || empty($phone) || empty($duedate)) {
if(empty($name)) {
echo "<font color='red'>Name field is empty.</font><br/>";
}
if(empty($phone)) {
echo "<font color='red'>Quantity field is empty.</font><br/>";
}
if(empty($duedate)) {
echo "<font color='red'>Due Date field is empty.</font><br/>";
}
//link to the previous page
echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
//insert data to database
$result = mysqli_query($mysqli, "INSERT INTO orders(name, phone, duedate, detail) VALUES('$name','$phone','$price', '$duedate', '$details')");
//display success message
echo "<font color='green'>Data added successfully.";
echo "<br/><a href='vieworder.php'>View Result</a>";
}
}
?>