-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsend_form_email.php
74 lines (63 loc) · 1.44 KB
/
send_form_email.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
<?php
/* Set e-mail recipient */
$myemail = "[email protected]";
/* Check all form inputs using check_input function */
if (isset($_GET["submit"])) {
$name = $_GET['name'];
$email = $_GET['email'];
$message = $_GET['message'];
}
else {
echo $myError;
}
$subject = "Report From OlympiaMC";
/* If input is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid.");
}
if (preg_match( '/[a-zA-Z]/', $cords )) {
show_error("Coordinates not valid.");
}
/* Let's prepare the message for the e-mail */
$message = "Hello,
This is a report from the OlympiaMC Bootstrap Template. Below is the information...
Name: $name
E-mail: $email
In-Game Coordinates: $cords
Message: $message
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
echo "<script>
window.location.href='index.html';
alert('Thanks, your report has been submitted.');
</script>";
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>