Хочу сделать бронирование мест на одном сайте.
с аяксом я даже не знакомился, а там код на нем.
Вот хтмл код:
<form action="./js/reservations.php" method="post" class="reservationForm" id="reservationForm">
<!-- column 1 -->
<div class="col col_1_2 alpha">
<div class="row field_select">
<label>Choose medical department:</label><br />
</div>
<div class="row field_text">
<label>Your full name:</label><br />
<input name="name" value="" id="name" class="inputtext required" size="40" type="text" />
</div>
<div id = 'emailId' class="row field_text">
<label>Your email address:</label><br />
<input name="email" value="" id="email" class="inputtext required" size="40" type="text" />
</div>
<div class="row">
<input type="submit" value="MAKE APPOINTMENT" id="send" class="btn-send" />
</div>
</div>
<!--/ column 1 -->
<!-- column 2 -->
<div class="col col_1_2 omega">
<div class="row field_date">
<div id="date_in"></div>
<input name="date_in_input" value="" id="date_in_input" type="hidden" />
<div class="notice_table"><span class="square-green">your selection</span> <span class="square-disable">not available</span></div>
</div>
</div>
<!--/ column 2 -->
<div class="field_submit">
<p class="sending"><img id="sending" src="./images/ajax-loader.gif" alt="" /></p>
</div>
</form>
Это присоединенный js код
jQuery(document).ready(function(){
tfuse_reservations_form();
});
function tfuse_reservations_form(){
var my_error;
jQuery("#send").bind("click", function(){
my_error = false;
jQuery("#reservationForm input, #reservationForm textarea, #reservationForm radio, #reservationForm select").each(function(i)
{
var surrounding_element = jQuery(this);
var value = jQuery(this).attr("value");
var check_for = jQuery(this).attr("id");
var required = jQuery(this).hasClass("required");
if(check_for == "email"){
surrounding_element.removeClass("error valid");
baseclases = surrounding_element.attr("class");
if(!value.match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){
surrounding_element.attr("class",baseclases).addClass("error");
my_error = true;
}else{
surrounding_element.attr("class",baseclases).addClass("valid");
}
}
if(required && check_for != "email"){
surrounding_element.removeClass("error valid");
baseclases = surrounding_element.attr("class");
if(value == ""){
surrounding_element.attr("class",baseclases).addClass("error");
my_error = true;
}else{
surrounding_element.attr("class",baseclases).addClass("valid");
}
}
if(jQuery("#reservationForm input, #reservationForm textarea, #reservationForm radio, #reservationForm select").length == i+1){
if(my_error == false){
jQuery("#reservationForm p.notice, #reservationForm #send").hide();
jQuery("#reservationForm p.sending").show();
var $datastring = "ajax=true";
jQuery("#reservationForm input, #reservationForm textarea, #reservationForm radio, #reservationForm select").each(function(i)
{
var $name = jQuery(this).attr('name');
$value = encodeURIComponent(jQuery(this).attr('value'));
$datastring = $datastring + "&" + $name + "=" + $value;
});
jQuery.ajax({
type: "POST",
data: $datastring,
url: "./js/reservations.php",
success: function(response){
jQuery("#reservationForm p.sending, #reservationForm p.notice").hide();
if(response) {
alert('сообещние отправлено')
} else {
alert('нет')
}
}
});
}
}
});
return false;
});
}
Вот тут я пытался писать reservation.php
$name = $_POST['name'];
$email = $_POST['email'];
$date = $_POST['date'];