When the user logs in, I store the email in $email (I have also tried global $email). Then I have a form where they type in their roommate’s name to search for already scheduled appointments.
AJAX
$("#reserveAPickupAppointmentForm3").submit (function() {
roommate = $("#roommate").val();
$.post('roommateSearch.php', 'val=' + roommate, function (response) {
$("#roommateResults").html(response);
});
return false;
});
On roommateSearch.php, if an appointment is found, you can click on the appointment to schedule one for yourself at the same time. Then I take that information and post it to another processing page at postAppointment.php so that I can insert it in the database.
$(".confirmAppointment").click (function() {
$(".confirmAppointment").unbind("click");
var location = $(".reserveAPickupAppointmentLocation", entry).text();
var subLocation = $(".reserveAPickupAppointmentSubLocation", entry).text();
var startTime = $(".reserveAPickupAppointmentStartTime", entry).text();
var endTime = $(".reserveAPickupAppointmentEndTime", entry).text();
var date = $(".reserveAPickupAppointmentDate", entry).text();
alert (location + subLocation + startTime + endTime + date);
$.post("postAppointment.php", "location=" + location + "subLocation=" + subLocation + "startTime=" + startTime + "endTime=" + endTime + "date=" + date, function (response) {
alert (response);
});
});
In order to create the appointment correctly, though, I need to recapture the user’s email and add it to the SQL statement. But, when I call $email on postAppointment.php, nothing shows up. How would I do this?
I have flirted with the idea of including it on the original form as a hidden input textbox with $email as the value, then passing that info with the rest of it, but surely there is an easier way…I’m hoping there is a way to get postAppointment.php to recognize $email.
When user succesfully logs in, Keep his email id in a session variable. You can access this variable value in your ajax processing page.
Check whether you have added “
php session_start()” in the page where you are accesssing session variable.