-
Notifications
You must be signed in to change notification settings - Fork 1
/
contact.php
79 lines (66 loc) · 1.44 KB
/
contact.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
73
74
75
76
77
78
79
<?php
$name = $email = $subject = $message = $msg = "";
$nameErr = $emailErr = $subjectErr = $messageErr = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
echo $nameErr;
} else {
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
echo $nameErr;
} else {
$name = test_input($_POST["name"]);
echo $name;
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
echo $emailErr;
} else {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email";
echo $emailErr;
}else{
$email = test_input($_POST["email"]);
echo $email;
}
}
if (empty($_POST["subject"])) {
$subjectErr = "Subject is required";
echo $subjectErr;
} else {
$subject = test_input($_POST["subject"]);
echo $subject;
}
if (empty($_POST["message"])) {
$messageErr = "Message is required";
echo $messageErr;
} else {
$message = test_input($_POST["message"]);
echo $message;
}
}
$msg = "
<html>
<head>
<title>Greetings from selingonal.github.io!</title>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
<tr>
<td>$name</td>
<td> $email</td>
</tr>
</table>
<p>$message</p
</body>
</html>
";
mail("[email protected]", $subject, $msg);
header("Location: index.html");
?>