source:
ApproveOrder.php
Last change on this file was e3d4e0a, checked in by , 6 days ago | |
---|---|
|
|
File size: 975 bytes |
Rev | Line | |
---|---|---|
[e3d4e0a] | 1 | <?php |
2 | ||
3 | session_start(); | |
4 | ||
5 | if(!isset($_SESSION['user_ID']) || !isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) { | |
6 | header("Location: ./Log In.php"); | |
7 | } | |
8 | ||
9 | require './connect.php'; | |
10 | require './SendEmail.php'; | |
11 | ||
12 | if(!isset($_POST['order_id'])) { | |
13 | header("Location: ./PendingOrders.php"); | |
14 | die(); | |
15 | } | |
16 | ||
17 | $res = mysqli_query($conn, "SELECT * FROM orders WHERE id={$_POST['order_id']};"); | |
18 | ||
19 | if(mysqli_num_rows($res) >= 1) { | |
20 | $row = $res->fetch_assoc(); | |
21 | $email = mysqli_query($conn, "SELECT email FROM users WHERE user_id={$row['user_id']}")->fetch_assoc()['email']; | |
22 | ||
23 | if($row['status'] == 'p') { | |
24 | mysqli_query($conn, "UPDATE orders SET status = 'a', shipped_date = CURDATE() WHERE id={$_POST['order_id']};"); | |
25 | SendMail($email, "InnovaDB Update\n", "Your order with id({$row['id']}) has been APPROVED\n"); | |
26 | } | |
27 | } | |
28 | ||
29 | ||
30 | header("Location: ./PendingOrders.php"); | |
31 | die(); | |
32 | ?> |
Note:
See TracBrowser
for help on using the repository browser.