-
Notifications
You must be signed in to change notification settings - Fork 24
/
contactpage.php
36 lines (36 loc) · 1018 Bytes
/
contactpage.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
<? php
if (isset($_POST['name']))
$name = $_POST['name'];
if (isset($_POST['email']))
$email = $_POST['email'];
if (isset($_POST['message']))
$message = $_POST['message'];
if (isset($_POST['subject']))
$subject = $_POST['subject'];
if ($name === '') {
echo "Name cannot be empty So you have to complte it..";
die();
}
if ($email === '') {
echo "Email cannot be empty So you have to complte it..";
die();
} else {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Email format is invalid So you have to complte it..";
die();
}
}
if ($subject === '') {
echo "Subject cannot be empty. So you have to complte it.";
die();
}
if ($message === '') {
echo "Message cannot be empty.";
die();
}
$content = "From: $name \nEmail: $email \nMessage: $message";
$recipient = "youremail@here.com";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $content, $mailheader) or die("Error!");
echo "Email sent!";
?>