-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemailform.php
More file actions
66 lines (51 loc) · 1.87 KB
/
emailform.php
File metadata and controls
66 lines (51 loc) · 1.87 KB
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
<?php
require_once 'include/scurvy/src/scurvy.php';
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "inquiry@emp-d.com";
$email_subject = "New e-mail subscriber";
function died($error) {
// your error code can go here
$template = new Scurvy( 'signup.html', 'templates/' );
$template->set( 'title', 'Extensible Monitoring Platform' );
$form = "We are very sorry, but there were error(s) found with the form your submitted. ";
$form.= "These errors appear below.<br /><br />";
$form.= $error."<br /><br />";
$template->set( 'form', $form );
echo $template->render();
die();
}
// validation expected data exists
if(!isset($_POST['email'])) {
died('We are sorry, but there appears to be a problem with the email your submitted.');
}
$email_from = $_POST['email']; // required
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Email: ".clean_string($email_from)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
//RENDER VALID VIEW
$template = new Scurvy( 'signup.html', 'templates/' );
$template->set( 'title', 'Extensible Monitoring Platform' );
$form = '<p>Thank you for contacting us. We will be in touch with you as soon as we can!</p>';
$template->set( 'form', $form );
echo $template->render();
}else{
header("Location: signup.php");
}
?>