-
Notifications
You must be signed in to change notification settings - Fork 0
/
form-send.php
60 lines (50 loc) · 1.97 KB
/
form-send.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
<?php
/*
* Form processing for the forms present in the template
*/
$message = '';
// Alert messages
$success = '<div class="alert alert-success" role="alert">'
. '<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>'
. '<strong>Thank you</strong>, Your message has been sent!</div>';
$fail = '<div class="alert alert-danger" role="alert">'
. '<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>'
. '<strong>There was a problem</strong>, your message was not sent. Please try and submit the form again.</div>';
// About Us Page Form Submission
if ( isset( $_POST['from_form']) && $_POST['from_form'] == 'about-us-page') {
if (isset($_POST['email'])) {
$subject = 'Contact Form Submission';
$message = send_mail_confirm( $_POST['name'], $_POST['email'], $subject, $_POST['message'] );
}
if( $message ){
$message = $success;
} else {
$message = $fail;
}
// Single Blog Entry Form
} elseif (isset($_POST['from_form']) && $_POST['from_form'] == 'blogpage') {
if (isset($_POST['email'] ) ) {
$message = send_mail_confirm( $_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message'], '', $_POST['url'] );
if( $message ){
$message = $success;
} else {
$message = $fail;
}
}
}
echo json_encode($message); // Send back our success or fail message
function send_mail_confirm( $name, $email, $subject, $message, $phone='', $url=''){
$to = 'whatevers@mailinator.com'; // Your Email Address
$msg = '<p>Name : ' . $name . '</p>';
$msg .= '<p>Email : ' . $email . '</p>';
if ($phone) {
$msg .= '<p>Phone Number : ' . $phone . '</p>';
}
if ($url) {
$msg .= '<p>URL : ' . $url . '</p>';
}
$msg .= '<p>Message : ' . $message . '</p>';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
return mail($to, $subject, $msg, $headers);
}