-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpant_order.php
More file actions
136 lines (118 loc) · 4.32 KB
/
Copy pathpant_order.php
File metadata and controls
136 lines (118 loc) · 4.32 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
@include 'config.php';
include('login_check.php');
error_reporting(0);
session_start();
$pant_type = $_GET['pant_type'];
$order_total = $_GET['pant_price'];
$cid = $_SESSION['client_id'];
$delivery_date = $_POST['delivery_date'];
$today = date("Y-m-d");
if (!empty($cid) and !empty($delivery_date) and ($delivery_date > $today)) {
if (mysqli_connect_errno()) {
die('Connect Error : ' . mysqli_connect_error());
} else {
$order_insert = "INSERT INTO orders(client_id,pant_type,delivery_date,order_total)
VALUES('$cid','$pant_type','$delivery_date','$order_total')";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $order_insert)) {
die(mysqli_error($conn));
}
mysqli_stmt_execute($stmt);
//echo "<script type='text/javascript'>alert('Order placed successfully')</script>";
header("Location: " . SITEURL . "pants.php");
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pants-Place Order</title>
<link rel="stylesheet" href="place_order.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
<link rel="icon" type="image/x-icon" href="Images/Favicon.png">
</head>
<body>
<header>
<nav class="navbar">
<div class="navdiv">
<div class="nav-logo">
<a href="<?php echo SITEURL; ?>Hom.php">
<img src="Images/SmartStitchLogo.png" alt="SmartStitch" width="180px ">
</a>
</div>
<div class="heading">PLACE ORDER</div>
</div>
</nav>
</header>
<main>
<div class="order">
<h3>ORDER DETAILS:</h3>
<table>
<tr>
<th>Client ID</th>
<th>:</th>
<td><?php echo $_SESSION['client_id']; ?></td>
</tr>
<tr>
<th>Client Name</th>
<th>:</th>
<td><?php echo $_SESSION['client_name']; ?></td>
</tr>
<tr>
<th>Pant Type</th>
<th>:</th>
<td><?php echo $pant_type; ?></td>
</tr>
<tr>
<th>Order Total</th>
<th>:</th>
<td>Rs. <?php echo $order_total; ?></td>
</tr>
<tr>
<th>Mode of Payment</th>
<th>:</th>
<td>Cash on Delivery</td>
</tr>
</table>
<form action="" method="post">
<div class="expecteddelivery">
<label for="delivery_date">Expected delivery date : </label>
<input class="date" type="date" id="delivery_date" name="delivery_date"><br>
</div>
<p id="alertMessage"><i class="fa-solid fa-triangle-exclamation" style="color: #2b300d; font-size:16px"></i> Please select a date on or after today.</p>
<div class="submit">
<button type="submit" onclick="message()">Place order</button>
</div>
</form>
</div>
</main>
<script>
const delivery_date = document.getElementById('delivery_date');
const alertMessage = document.getElementById('alertMessage');
const today = new Date();
function message() {
if (delivery_date.value.length != 0) {
const selectedDate = new Date(delivery_date.value);
if (selectedDate > today) {
alert("Order placed Successfully");
} else {
alert("Please select a future date for delivery");
}
} else {
alert("Please enter Date");
}
}
delivery_date.addEventListener('change', function() {
const selectedDate = new Date(this.value);
if (selectedDate < today) {
alertMessage.style.display = 'block';
} else {
alertMessage.style.display = 'none';
}
});
</script>
</body>
</html>