-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-contact.php
197 lines (187 loc) · 12.4 KB
/
page-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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
//response generation function
$response = "";
//function to generate response
function my_contact_form_generate_response($type, $responseMessage){
global $response;
if($type == "success") $response = "<div class='alert alert-success'>{$responseMessage}</div>";
else $response = "<div class='alert alert-warning'>{$responseMessage}</div>";
}
//response messages
$not_human = "Someone can't add up. It wasn't us though."; $missing_content = "Please fill out ALL of the boxes."; $email_invalid = "Invalid email address."; $message_unsent = "Your message was not sent due to an Server Error on our side. Please Try Again.<br>If the problem persists, please try again later or send us an email."; $message_sent = "Great! Your message has been sent to us.";
//user posted variables
$name = $_POST['message_name'];
$email = $_POST['message_email'];
$radioselect = $_POST['inlineRadioOptions'];
$messageText = $_POST['message_text'];
$human = $_POST['message_human'];
//php mailer variables
$subject = $radioselect . " - From: " . $name . "\r\n";
if ($radioselect == "Galas") {
$toUs = "Gala Coordinator <[email protected]>";
$toSender = '' . $name . ' <' . $email . '>';
$headersUs = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $name . ' <[email protected]>', 'Reply-To: ' . $name . ' <' . $email . '>');
$headersSender = array('Content-Type: text/html; charset=UTF-8', 'From: Chester-le-Street ASC <[email protected]>', 'Reply-To: Gala Coordinator <[email protected]>');
}
if ($radioselect == "Membership Enquiries") {
$toUs = "Membership Secretary <[email protected]>";
$toSender = '' . $name . ' <' . $email . '>';
$headersUs = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $name . ' <[email protected]>', 'Reply-To: ' . $name . ' <' . $email . '>');
$headersSender = array('Content-Type: text/html; charset=UTF-8', 'From: Chester-le-Street ASC <[email protected]>', 'Reply-To: Membership Secretary <[email protected]>');
}
if ($radioselect == "Other Enquiries") {
$toUs = "Enquiries <[email protected]>";
$toSender = '' . $name . ' <' . $email . '>';
$headersUs = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $name . ' <[email protected]>', 'Reply-To: ' . $name . ' <' . $email . '>');
$headersSender = array('Content-Type: text/html; charset=UTF-8', 'From: Chester-le-Street ASC <[email protected]>', 'Reply-To: Enquiries <[email protected]>');
}
if ($radioselect == "Website Comments") {
$toUs = "Web Team <[email protected]>";
$toSender = '' . $name . ' <' . $email . '>';
$headersUs = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $name . ' <[email protected]>', 'Reply-To: ' . $name . ' <' . $email . '>');
$headersSender = array('Content-Type: text/html; charset=UTF-8', 'From: Chester-le-Street ASC <[email protected]>', 'Reply-To: Web Team <[email protected]>');
}
if ($radioselect == "Welfare") {
$toUs = "CLS ASC Welfare <[email protected]>";
$toSender = '' . $name . ' <' . $email . '>';
$headersUs = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $name . ' <[email protected]>', 'Reply-To: ' . $name . ' <' . $email . '>');
$headersSender = array('Content-Type: text/html; charset=UTF-8', 'From: Chester-le-Street ASC <[email protected]>', 'Reply-To: CLS ASC Welfare <[email protected]>');
}
if(!$human == 0){
if($human != 2) my_contact_form_generate_response("error", $not_human); //not human!
else {
//validate email
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
my_contact_form_generate_response("error", $email_invalid);
else //email is valid
{
//validate presence of name and message
if(empty($name) || empty($radioselect) || empty($messageText)){
my_contact_form_generate_response("error", $missing_content);
}
else //ready to go!
{
$sentUs = wp_mail($toUs, $subject, $message = "
<p style=\"font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">" . $messageText . "</p>
<ul style=\"font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;padding:0 0 0 1rem;\">
<li>From " . $name . "</li>
<li>Reply to <a href=\"mailto:" . $email . "\">" . $email . "</a></li>
</ul>
<hr>
<p style=\"margin-bottom:0;font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">This email has been generated by the web contact form on our website. Several people may have recieved this email. There is no need to forward it on if you do not personally need to take action on it</p>
<p style=\"font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">For support contact [email protected]</p>
" . "\r\n\r\n", $headersUs);
$sentSender = wp_mail($toSender, $subject, $message = "
<img style=\"width:100%;max-width:200px;\" src=\"https://www.chesterlestreetasc.co.uk/wp-content/themes/chester/img/chesterLogo.png\" alt=\"Chester-le-Street ASC\">
<p style=\"font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">Thank you for getting in touch with us using the <a href=\"https://www.chesterlestreetasc.co.uk/contact\">Online Contact Form</a>.</p>
<p style=\"font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">Below is the message you sent to " . $radioselect . "</p>
<p style=\"font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">" . $messageText . "</p>
<hr>
<p style=\"margin-bottom:0;font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">This email has been generated by the web contact form on our website. We'll be in touch soon. You don't need to take any further action.</p>
<p style=\"font-family:\"Open Sans\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;\">For support contact [email protected]</p>
" . "\r\n\r\n", $headersSender);
if($sentUs && $sentSender) my_contact_form_generate_response("success", $message_sent); //message sent!
else my_contact_form_generate_response("error", $message_unsent); //message wasn't sent
}
}
}
}
else if ($_POST['submitted']) my_contact_form_generate_response("error", $missing_content);
?>
<?php get_header(); ?>
<?php get_template_part( 'pageheader' ); ?>
<!-- Page Content -->
<div class="container">
<div class="row">
<main class="col-md-12 blog-main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('post blog-post'); ?> >
<h1 class="entry entry-title"><?php the_title(); ?></h1>
<div class="row">
<div class="col-lg-6">
<div class="entry clearfix">
<?php the_content(); ?>
</div>
</div>
<div class="col-lg-6">
<div class="well" id="respond">
<?php echo $response; ?>
<form action="<?php the_permalink(); ?>" method="post" class="form-horizontal" id="contact-form-link">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="message_name" placeholder="Your Name" value="<?php echo esc_attr($_POST['message_name']); ?>" required>
</div>
<div class="form-group">
<label for="message_email">Email</label>
<input type="text" class="form-control" name="message_email" placeholder="Your Email Address" value="<?php echo esc_attr($_POST['message_email']); ?>" required>
</div>
<div class="custom-controls-stacked">
<label for="inlineRadioOptions">Subject</label>
<div class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="Galas" required>
<label class="custom-control-label" for="inlineRadio1">Galas</label>
</div>
<div class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="Membership Enquiries" required>
<label class="custom-control-label" for="inlineRadio2">Membership Enquiries</label>
</div>
<div class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="inlineRadioOptions" id="inlineRadio5" value="Welfare" required>
<label class="custom-control-label" for="inlineRadio5">Welfare</label>
</div>
<div class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="inlineRadioOptions" id="inlineRadio4" value="Website Comments" required>
<label class="custom-control-label" for="inlineRadio4">Website Comments and Online Account Support</label>
</div>
<div class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="Other Enquiries" required>
<label class="custom-control-label" for="inlineRadio3">Other Enquiries</label>
</div>
</div>
<div class="form-group">
<label for="message_text">Message</label>
<textarea type="text" class="form-control" name="message_text" placeholder="Go on and Talk" rows="6" required><?php echo esc_textarea($_POST['message_text']); ?></textarea>
</div>
<div class="form-group d-none">
<label for="message_human">Are you Human?</label>
<div class="input-group">
<input type="text hidden" class="form-control" name="message_human" placeholder="Hint - The Answer is 2" value="2"><span class="input-group-addon"> + 3 = 5</span>
</div>
</div>
<input type="hidden" name="submitted" value="1">
<p class="mb-0">
<button class="btn btn-success " type="submit">Submit</button>
</p>
</form>
<!--
<div class="p-3 bg-warning">
<p class="mb-0">
<strong>
We're experiencing some technical problems with our
Web Contact Form
</strong>
</p>
<p>
As a result, we've temporarily closed this service.
</p>
<p>
In the meantime, you can contact us using the Email
Addresses on this page, or via Facebook Messenger.
</p>
<p class="mb-0">
To discuss joining the club, please contact <a
class="text-dark"
href="mailto:[email protected]">[email protected]</a>
</p>
</div>
-->
</div>
</div>
</div>
</div>
<?php endwhile; endif; ?>
</main>
</div>
</div>
<!-- Content ENDS -->
<?php get_footer(); ?>