-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.php
33 lines (28 loc) · 1.47 KB
/
backend.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
<?php
if(!empty($_POST['email']))
{
$to="[email protected]";
$email = $_POST['email'];
$name = $_POST['name'];
$subject = "New Contact From $name";
$message = $_POST['message'];
$headers = "From:" . $email;
echo mail($to,$subject,$message,$headers);
$data = array("value1" => $email, "value2" => $name, "value3" => $message);
$data_string = json_encode($data);
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
//Valid email!
$ch = curl_init("https://maker.ifttt.com/trigger/form_submitted/with/key/cGOWs6Ut6i3rlsz5mqDYRE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
$result = curl_exec($ch);
echo $result;
} else {
echo "Invalid email";
}
}
?>