<head>
<link href="css/bookingform.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1 style="font-family: Helvetica, Verdana, Geneva, Tahoma, sans-serif;">Request your Booking</h1>
<form method="post" action="send_contactform_email.php" class="cf">
<div class="half left cf">
<input name="firstname" type="text" id="input-firstname" placeholder="First Name *">
<input name="lastname" type="text" id="input-lastname" placeholder="Last Name *">
<input name="email" type="email" id="input-email" placeholder="Email address *">
<input name="mobile" type="text" id="input-mobile" placeholder="Mobile Number *">
<input name="attendees" type="text" id="input-attendees" placeholder="Number of Guests *">
<input name="coupon" type="text" id="input-coupon" placeholder="Coupon/Gift Code">
</div>
<div class="half right cf">
<select name="bookingtype" id="input-bookingtype">
<option value="none" selected>Please select a booking type</option>
<option value="rifle">Rifle Shooting Experience (£59)</option>
<option value="extended">Extended Experience (£25)**</option>
</select>
<select name="bookingdate" id="input-bookingdate">
<option value="none" selected>Please select a booking date</option>
<option value="22/07/2017">22nd July 2017 - Limited spaces avaliable!</option>
<option value="05/08/2017">5th August 2017</option>
<option value="09/09/2017">9th September 2017</option>
<option value="10/09/2017">10th September 2017</option>
<option value="07/10/2017">7th October 2017</option>
<option value="08/10/2017">8th October 2017</option>
</select>
<textarea name="message" type="text" id="input-message" placeholder="Any Information/Requests"></textarea>
</div>
<input type="submit" value="Submit" id="input-submit">
</form>
</body>@charset "utf-8";
/* CSS Document */
@import url(http://fonts.googleapis.com/css?family=Merriweather);
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html, body {
font-family: 'Merriweather', sans-serif;
padding: 1em;
}
h1 {
text-align: center;
color: #000000;
text-shadow: 1px 1px 0 white;
font-family: cool_crayon, Verdana, Geneva, sans-serif
}
form {
max-width: 600px;
text-align: center;
margin: 20px auto;
}
form select {
border: 0;
outline: 0;
padding: 1em;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
display: block;
width: 100%;
margin-top: 1em;
font-family: 'Merriweather', sans-serif;
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
resize: none;
}
form select:focus {
-moz-box-shadow: 0 0px 2px #e74c3c !important;
-webkit-box-shadow: 0 0px 2px #e74c3c !important;
box-shadow: 0 0px 2px #e74c3c !important;
}
form input, form textarea {
border: 0;
outline: 0;
padding: 1em;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
display: block;
width: 100%;
margin-top: 1em;
font-family: 'Merriweather', sans-serif;
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
resize: none;
}
form input:focus, form textarea:focus {
-moz-box-shadow: 0 0px 2px #e74c3c !important;
-webkit-box-shadow: 0 0px 2px #e74c3c !important;
box-shadow: 0 0px 2px #e74c3c !important;
}
form #input-submit {
color: white;
background: #25524D;
cursor: pointer;
font-size: large;
}
form #input-submit:hover {
-moz-box-shadow: 0 1px 1px 1px rgba(170, 170, 170, 0.6);
-webkit-box-shadow: 0 1px 1px 1px rgba(170, 170, 170, 0.6);
box-shadow: 0 1px 1px 1px rgba(170, 170, 170, 0.6);
}
form textarea {
height: 213px;
}
.half {
float: left;
width: 48%;
margin-bottom: 1em;
}
.right {
width: 50%;
}
.left {
margin-right: 2%;
}
@media (max-width: 480px) {
.half {
width: 100%;
float: none;
margin-bottom: 0;
}
}
/* Clearfix */
.cf:before,
.cf:after {
content: " ";
/* 1 */
display: table;
/* 2 */
}
.cf:after {
clear: both;
}
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "Booking Request Submission";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['firstname']) ||
!isset($_POST['lastname']) ||
!isset($_POST['email']) ||
!isset($_POST['mobile']) ||
!isset($_POST['bookingtype']) ||
!isset($_POST['bookingdate']) ||
!isset($_POST['attendees'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$firstname = $_POST['firstname']; // required
$lastname = $_POST['lastname']; // required
$email = $_POST['email']; // required
$mobile = $_POST['mobile']; // required
$attendees = $_POST['attendees']; // required
$bookingtype = $_POST['bookingtype']; // required
$bookingdate = $_POST['bookingdate']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
$error_message .= 'The email address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$firstname)) {
$error_message .= 'The first name you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$lastname)) {
$error_message .= 'The last name you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Booking Form Submission.";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($firstname)."n";
$email_message .= "Last Name: ".clean_string($lastname)."n";
$email_message .= "Email: ".clean_string($email)."n";
$email_message .= "Mobile Number: ".clean_string($mobile)."n";
$email_message .= "Number of Guests: ".clean_string($attendees)."n";
$email_message .= "Message: ".clean_string($message)."n";
$email_message .= "Coupon: ".clean_string($coupon)."n";
$email_message .= "Booking Type: ".clean_string($bookingtype)."n";
$email_message .= "Booking Date: ".clean_string($bookingtype)."n";
// create email headers
$headers = 'From: '.$email_from."rn".
'Reply-To: '.$email_from."rn" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
<center>
<p style="font-size:large; font-family: Helvetica, Verdana, Geneva, Tahoma, sans-serif;"><b>Thank you for sending us a booking request! We will be in touch soon!</b><br /><br />
<img src="images/saa_logo_black_900w.png" width="800" height="135" /></p>
</center>
<?php
header( "refresh:10; url=contactform.php" );
?>
<?php
}
?>
برچسب:
نویسنده: آیلین رضوانی