/
contact.php
83 lines (57 loc) · 2.99 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
80
81
82
83
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Mark Katzman - Writer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<style>
#contact { border: 1px solid white; }
.antispam-field { margin-top: 10px;}
</style>
</head>
<body>
<div id="container">
<div id="leftcol">
<? require('leftnav.inc.php'); ?>
</div>
<div id="rightcol">
<? require ("includes/antispam-form.inc.php"); ?>
<? require ("includes/validate-fields.inc.php"); ?>
<?
$form_fields[] = array('name' => 'name', 'type' => 'text', 'size' => '40', 'label' => 'Your Name', 'required' => 'true');
$form_fields[] = array('name' => 'email', 'type' => 'text', 'size' => '40', 'label' => 'Your Email', 'required' => 'true');
$form_fields[] = array('name' => 'subject', 'type' => 'text', 'size' => '40', 'label' => 'Subject', 'required' => 'true');
$form_fields[] = array('name' => 'body', 'type' => 'textarea', 'cols' => '40', 'rows' => '10', 'label' => 'Message', 'required' => 'true');
$form_fields[] = array('name' => 'submit', 'type' => 'submit', 'value' => 'Submit');
$shuffle = array(array('name', 'email'));
$form_values = antispam_form_get_values($form_fields);
if($form_values) {
if(antispam_form_get_errors()) $form_errors[] = antispam_form_get_errors();
if(!valid_name_field($form_values['name'])) $form_errors[] = 'You must enter your name!';
if(!valid_comment_field($form_values['subject'])) $form_errors[] = 'You must enter a subject!';
if(!valid_email_field($form_values['email'])) $form_errors[] = 'You must enter a valid email address!';
if(!valid_comment_field($form_values['body'])) $form_errors[] = 'You must enter a message!';
if($form_errors) {
foreach($form_errors as $this_error) print "<p style='color: red'><strong>$this_error</strong></p>";
print antispam_form_write_form ($form_fields, $form_values, $shuffle);
} else {
$notify = 'Mark Katzman <mark@markkatzman.com>';
$script_name = "http://{$_SERVER['HTTP_HOST']}";
$script_name .= $_SERVER['REQUEST_URI'];
$message = $form_values['body'];
$message .= "\n\nThe form was submitted from the following page:\n$script_name";
$bcc = "Bcc: mccaffry@artzar.com\r\n";
$from = $form_values['name']." <".$form_values['email'].">";
$subject = "[contact form] ".$form_values['subject'];
$wasSent = mail($notify, $subject, $message, "From: $from\r\n$bccX-Mailer: PHP/" . phpversion());
if($wasSent) echo "<div><strong>Your message has been sent!</strong></div>";
else echo "<div style='color: red'><strong>Could not send message. Please try again at a later time!</strong></div>";
}
} else {
print antispam_form_write_form ($form_fields, '', $shuffle);
}
?>
</div>
</div>
</body>
</html>