-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_handler.php
71 lines (50 loc) · 1.56 KB
/
order_handler.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
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
<?php
$orderPost = file_get_contents('php://input');
$order = json_decode($orderPost);
$result = new stdClass();
function sendUserError($msg)
{
global $result;
mail("[email protected]", "Error on Event Sales", $msg);
header("Content-type: application/json");
$result->result = false;
echo json_encode($result);
exit();
}
function sendUserSuccess()
{
global $result;
header("Content-type: application/json");
$result->result = true;
echo json_encode($result);
exit();
}
//$conn
include('/var/www/vhosts/justinwylliephotography.com/event_sales_db.php');
if ($conn->connect_error) {
var_dump("here1");
$msg = "Connect error. Check log. Client email was: '" . $order->customerData->email . "'";
sendUserError($msg) ;
}
$conn->set_charset("utf8") ;
$orderPost = $conn->real_escape_string($orderPost);
if (!($stmt = $conn->prepare("INSERT INTO orders (order_json) VALUES (?)")))
{
$msg = "Connect error. Check log. Client email was: '" . $order->customerData->email . "'";
sendUserError($msg) ;
}
if (!$stmt->bind_param("s", $orderPost))
{
$msg = "Connect error. Check log. Client email was: '" . $order->customerData->email . "'";
sendUserError($msg) ;
}
if (!$stmt->execute() )
{
$msg = "Connect error. Check log. Client email was: '" . $order->customerData->email . "'";
sendUserError($msg) ;
}
$result->orderId = mysqli_insert_id($conn);
mail("[email protected]", "Order on OCVA Event Sales: Order Id: ". $result->orderId, $orderPost);
sendUserSuccess();
$conn->close();
?>