-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.php
79 lines (74 loc) · 2 KB
/
form.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<?php;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name1"])){
$nameErr = "Who are you?";
} else {
$name1 = test_input($_POST["name1"]);
if (!preg_match("/^[a-zA-Z\D ]*$/", $name1)) {
$nameErr = "Just names, no numbers.";
}
}
if (empty($_POST["email"])){
$emailErr = "How should we contact you?";
} else {
$email = test_input($_POST["email"]);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) {
$emailErr = "We need a real address to spam.";
}
}
if (empty($_POST["comment"])){
$commentErr = "";
} else {
$comment = test_input($_POST["comment"]);
}
if (empty($_POST["attend"])){
$attendErr = "This is the RSVP part!";
} else {
$attend = test_input($_POST["attend"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
function spamcheck($field) {
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
if(filter_var($field, FILTER_VALIDATE_EMAIL)) {
return TRUE;
} else {
return FALSE;
}
}
if (isset($_POST["submit"])){
if (isset($_POST["name1"])){
if (preg_match("/^[a-zA-Z\D ]*$/", $name1)) {
if (isset($_POST["email"])){
$mailcheck = spamcheck($_POST["email"]);
if ($mailcheck==FALSE){ //do nothing
} else {
if (isset($_POST["attend"])){
$subject = "weeding RSVP";
$name1 = $_POST["name1"];
$attend = $_POST["attend"];
$comment = $_POST["comment"];
$message = $name1 . "\r\n" . $email . "\r\n" . $attend . "\r\n" . $comment;
$email = $_POST["email"];
$message = wordwrap($message, 70, "\r\n");
mail("sarahandaj831@yahoo.com", $subject, $message, "From: none@email.com\n");
$success = '<div class="confirm">Thanks for your response!</div>';
}
}
}
}}
}
?>
</body>
</html>