-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontactwe.php
56 lines (51 loc) · 1.55 KB
/
contactwe.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
<?php
// VALUES FROM THE FORM
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['msg'];
// ERROR & SECURITY CHECKS
if ( ( !$email ) ||
( strlen($_POST['email']) > 200 ) ||
( !preg_match("#^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$#", $email) )
)
{
print "Error: Invalid E-Mail Address";
exit;
}
if ( ( !$name ) ||
( strlen($name) > 100 ) ||
( preg_match("/[:=@\<\>]/", $name) )
)
{
print "Error: Invalid Name";
exit;
}
if ( preg_match("#cc:#i", $message, $matches) )
{
print "Error: Found Invalid Header Field";
exit;
}
if ( !$message )
{
print "Error: No Message";
exit;
}
if (eregi("\r",$email) || eregi("\n",$email)){
print "Error: Invalid E-Mail Address";
exit;
}
if (FALSE) {
print "Error: You cannot send to an email address on the same domain.";
exit;
}
// CREATE THE EMAIL
$headers = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $name <".$email.">\n";
$recipient = "[email protected]";
$subject = "Feedback from wePopulus.com";
$message = wordwrap($message, 1024);
// SEND THE EMAIL TO YOU
mail($recipient, $subject, $message, $headers);
// REDIRECT TO THE THANKS PAGE
header("location: thanks.php");
?>