-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontact-process.php
53 lines (43 loc) · 1.28 KB
/
contact-process.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
<?php
$errormsg = "";
if (empty($_POST["fname"])) {
$errormsg .= "Name required. ";
} else {
$fname = filter_var($_POST['fname'], FILTER_SANITIZE_STRING);
}
if (empty($_POST["email"])) {
$errormsg .= "Email required. ";
} else {
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
}
if (empty($_POST["phone"])) {
$errormsg .= "Phone required. ";
} else {
$phone = filter_var($_POST['phone'], FILTER_SANITIZE_NUMBER_INT);
}
if (empty($_POST["message"])) {
$errormsg .= "Message required. ";
} else {
$message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
}
$success = '';
if (!$errormsg){
//change recipient email and subject here
$to = "[email protected]";
$subject = "New AboutMe Demo Contact Form Submitted";
//prepare email body
$body_message = "";
$body_message .= "Name: " . $fname ."\n";
$body_message .= "email: " . $email ."\n";
$body_message .= "Phone: " . $phone ."\n";
$body_message .= $message;
$headers = 'From: '. $fname .' <'. $email .'>' . "\r\n" .
'Reply-To: ' . $email . "\r\n";
$success = mail($to, $subject, $body_message, $headers);
}
if ($success){
echo "success";
}else{
echo "Something went wrong: ".$errormsg;
}
?>