-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailer-new.php
37 lines (28 loc) · 1.35 KB
/
mailer-new.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
<?php
// Get the form fields, removes html tags and whitespace.
$name = strip_tags(trim($_POST["name"]));
$name = str_replace(array("\r","\n"),array(" "," "),$name);
$email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
$message = trim($_POST["message"]);
// Check the data.
if (empty($name) OR empty($message) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) {
// header("Location: http://www.webdesigncourse.co/omnifood/index.php?success=-1#form");
header("Location: https://lambochan.github.io/sethfoodchain/index.html?=-1#form");
exit;
}
// Set the recipient email address. Update this to YOUR desired email address.
$recipient = "<YOUR EMAIL HERE>";
// Set the email subject.
$subject = "New contact from $name";
// Build the email content.
$email_content = "Name: $name\n";
$email_content .= "Email: $email\n\n";
$email_content .= "Message:\n$message\n";
// Build the email headers.
$email_headers = "From: $name <$email>";
// Send the email.
mail($recipient, $subject, $email_content, $email_headers);
// Redirect to the index.html page with success code
// header("Location: http://www.webdesigncourse.co/omnifood/index.php?success=1#form");
header("Location: https://lambochan.github.io/sethfoodchain/index.hmtl?success=1#form");
?>