Hi all,
I am new to php and trying to desing a booking system.
the problem I have is how to retrive the session variable to use in a query.
the user logs in with a reference number, I pass the number to the next page to display details that are specific to that user.
I am using sessions.
the following is the code.
I want to use the session variable in the where part of the query
something like session varible = refnumber
to display details of the user that logged on.
your help would be appreciated
many thanks.
<?php
session_start();
include("db.php");
if(isset($_SESSION['valid_user'])){
echo '<strong>Your appointment reference number is: '.$_SESSION['valid_user'].' <br />';
$result = mysql_query("SELECT b.ref_num,
p.fname,
p.lname,
h.name,
h.location,
h.address,
t.app_day,
t.app_date,
t.app_time
FROM booking b, patient p, hospital h, time_slot t
WHERE b.nhs_num = p.nhs_num
AND b.hospital_id = h.hospital_id
AND b.slot_id = t.slot_id
ORDER BY b.ref_num")
or die(mysql_error());
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo "Name: ".$row['ref_num'];
echo " Age: ".$row['fname'];
}
mysql_close();
?>