-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateCoupon.php
More file actions
44 lines (38 loc) · 1.4 KB
/
updateCoupon.php
File metadata and controls
44 lines (38 loc) · 1.4 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
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
header('Access-Control-Allow-Headers: Origin, Content-Type');
header('Content-Type: application/json');
include '../admin/conn.php';
// Create new user account
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$inputs = json_decode(file_get_contents('php://input'), true);
$query = $conn->prepare(
"UPDATE coupons
SET description = ?, amount = ?, type = ?, minimum_required = ?, maximum_allowed = ?, start_time = ?, end_time = ?, categories = ?, subcategories = ?
WHERE code = ?"
);
$query->bind_param(
"ssssssssss",
$inputs['description'],
$inputs['amount'],
$inputs['type'],
$inputs['minimum_required'],
$inputs['maximum_allowed'],
$inputs['start_time'],
$inputs['end_time'],
$inputs['categories'],
$inputs['subcategories'],
$inputs['code']
);
if (!$query->execute()) {
// If insertion fails, return error message
echo json_encode($query->error);
}
else {
echo json_encode(1);
}
}
mysqli_close($conn);
?>