Hi all, I'm trying to use the jQuery datepicker to create a booking date selection thingy on a personal plugin I'm trying to develop.
This is the code I'm using to take an "arrival" date and a "departure" date, after click on the submit button the user is redirected to another page where he can compile the main form:
book_test.php
$(document).ready(function() {
var dates = $( '#arrival, #departure' ).datepicker({
defaultDate: '+1w',
changeMonth: true,
numberOfMonths: 1,
onSelect: function( selectedDate ) {
var option = this.id == 'arrival' ? 'minDate' : 'maxDate',
instance = $( this ).data( 'datepicker' ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( 'option', option, date );
}
});
});
...............
...............
...............
...............
<form name="grab" method="post" action="?page_id=52">
Arrival<br />
<input type="text" id="arrival" name="arrival">
Departure<br />
<input type="text" id="departure" name="departure"/>
<input type="submit" value="Send" alt="Send request">
</form>
Here the user can fill the main form with name and so on:
form_main.php
<input type="text" name="arrival" disabled="yes" value="<?php echo $_POST['arrival']; ?>">
<input type="text" name="departure" disabled="yes" value="<?php echo $_POST['departure']; ?>">
<input type="text" name="name">
...............
...............
...............
...............
<input type="submit" id="button" name="button" value="Send" />
I'm trying to send this form to email, but I receive all the fields except the dates selected by the user, this is a part of the code I wrote:
mail.php
$name = $_REQUEST["name"];
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$from = $_REQUEST["from"];
$verif_box = $_REQUEST["verif_box"];
$name = stripslashes($name);
$message = stripslashes($message);
$subject = stripslashes($subject);
$from = stripslashes($from);
$body .= "Arrival Date: " . trim(date("d/m/Y", $_POST["arrival"])) . "\n";
$body .= "Departure: " . trim(date("d/m/Y", $_POST["departure"])) . "\n";
$body .= "Name: " . trim(stripslashes($_POST["name"])) . "\n";
But it prints these dates:
Arrival Date: 01/01/1970
Departure Date: 01/01/1970
Any hint?
At the moment the 1st little form sends the 2 variables (arrival and departure) to the second one (the main form) correctly, but I can't figure out why when I click on the Submit button of the main form I can't receive the correct dates in the mail.
Hope someone could help!
Cheers