-
Notifications
You must be signed in to change notification settings - Fork 0
/
join.php
70 lines (62 loc) · 2.02 KB
/
join.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
<?php
$recipient = "president@emptysky.org";
$required = array("name", "email", "action");
if (count($_POST) && !($missing = get_missing_fields()))
send_mail();
else
spit_form($missing);
function get_missing_fields() {
global $required;
$missing = array();
foreach ($required as $field)
if (!$_POST[$field])
$missing[] = $field;
return $missing;
}
function send_mail() {
global $recipient;
mail(
$recipient,
"Empty Sky Mailing List Request",
"The following person wants to " . strtoupper($_POST['action']) . ":\n\n" .
" Name: " . $_POST['name'] . "\n" .
" Email: " . $_POST['email'] . "\n" .
"\nLove,\nYour Mother",
"From: Your Mother <$recipient>");
head();
echo "<h2>Thanks</h2><p>Your request has been submitted.</p>";
foot();
}
function spit_form($missing=array()) {
head();
echo "<h2>Join Our Mailing List</h2>";
if (count($missing))
echo "<p><b style='color: #800'> Hey! You didn't give me your " .
implode(" or ", $missing) . ". Try again.</b></p>";
?>
<form id="join-form" action="<?=$_SERVER['PHP_SELF']?>" method="post">
<div>
<label for="name">Full name:</label>
<input type="text" name="name" id="name" value="<?=htmlentities($_POST['name'])?>">
</div><div>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="<?=htmlentities($_POST['email'])?>">
</div><div>
<label for="action">I want to:</label>
<select name="action" id="action">
<option value="subscribe">subscribe</option>
<option value="unsubscribe">unsubscribe</option>
</select>
</div>
<input type="submit" value="Sign me up!">
</form>
<?php
foot();
}
function head() {
include(dirname(__FILE__) . "/new/header.phtml");
}
function foot() {
include(dirname(__FILE__) . "/new/footer.phtml");
}
?>