I did have a search before hand, yet couldn't find much that closely replicated the problem I am experiencing. I have recently set up a form to POST method using form elements and PHP. I can confirm that I am receiving the emails and the information for the rest of the fields, yet the <select>
and Jquery 'datepicker' elements are not passing any information through to email, they resolve as blank.
HTML code as follows:
<form method="POST" action="mail.php" id="contactform" class="centered">
<fieldset>
<input type="text" name="first_name" placeholder="First Name" required>
<div class="controls controls-row">
<input type="text" name="last_name" placeholder="Last Name" required>
</div>
<input type="email" name="email" placeholder="Email Address" required>
<div class="controls-row">
<input type="text" id="datepicker" name="check_in" placeholder="Check-in" required>
</div>
<div class="controls-row">
<input type="text" id="datepicker2" name="check_out" placeholder="Check-out" required>
</div>
<div class="controls-row">
<select id="modalselect" name="rooms">
<option value="0" selected="selected">Number of Rooms</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5+</option>
</select>
</div>
<div class="controls-row">
<select id="modalselect" name="people">
<option value="0" selected="selected">Number of People</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="1">8</option>
<option value="2">9</option>
<option value="3">10+</option>
</select>
</div>
<textarea rows="3" name="additional" input class="input-xparge" placeholder="Anything else?" class="span5"></textarea>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button type="submit" name="submit" input type="submit" form="contactform" class="btn btn-block btn-large btn-success" value="submit">Submit</button>
PHP code as follows:
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$check_in = $POST['check_in'];
$check_out = $POST['check_out'];
$rooms = $POST['rooms'];
$occupants = $POST['people'];
$additional = $_POST['additional'];
$from = "From: Babbacombe Hall Mailserver";
$to = "lloyd.rees09@bathspa.ac.uk";
$subject = "New Booking Enquiry";
$body = "First Name: $first_name\n Last Name: $last_name\n Email: $email\n Check In: $check_in\n Check Out: $check_out\n Number of Rooms: $rooms\n Number of Occupants: $occupants\n Additional Information: $additional";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
Your help and expertise would be greatly appreciated!
Replace this:
$check_in = $POST['check_in'];
$check_out = $POST['check_out'];
$rooms = $POST['rooms'];
$occupants = $POST['people'];
With this:
$check_in = $_POST['check_in'];
$check_out = $_POST['check_out'];
$rooms = $_POST['rooms'];
$occupants = $_POST['people'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.