forked from rpiambulance/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.stocking.php
72 lines (54 loc) · 1.97 KB
/
.stocking.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
69
70
71
72
<?php
// grab recaptcha library
require_once ".recaptchalib.php";
// grab secret key and to-address
require_once ".form_config.php";
// empty response
$response = null;
// check secret key
$reCaptcha = new ReCaptcha($secret);
$errors = array();
// array to pass back data
$data = array();
// Get the input ===============================================================
$formData = file_get_contents('php://input');
$input = json_decode($formData, true);
// if submitted check response
if (isset($input['g-recaptcha-response'])) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$input["g-recaptcha-response"]
);
}
if (!empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
$data['messageError'] = 'Please check the fields in red';
} else {
// if there are no errors, return a message
$data['success'] = true;
$data['messageSuccess'] = 'Thanks for reaching out! We will get back to you soon as possible!';
//**************************
//******SET TEMP VARS*******
//**************************
$name = $input['name'];
$facility = $input['facility'];
$items = $input['items'];
//**************************
//********CONSTANTS*********
//**************************
// EMAIL TO THE O-BOARD ************************
$email_message =
"\nA stocking issue has been reported through the website. Details are included below:\n" .
"\n".
"\nFacility: ". $facility.
"\nItems: " . $items.
"\nReported by: " . $name;
$subject= $facility . " stocking issue reported!";
$email= '[email protected]';
$headers_requester= "From: [email protected]";
@mail($email, $subject, $message, $headers_requester);
}
// return all our data to an AJAX call =========================================
echo json_encode($data);