By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,400 Members | 1,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,400 IT Pros & Developers. It's quick & easy.

Help with Using sessions

P: 1
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();


?>
Aug 6 '07 #1
Share this Question
Share on Google+
1 Reply


100+
P: 228
jx2
u need to register a session variable

[php]
if( ! isset($_SESSION[refnumber]) session_register("refnumber");
[/php]

this code is all you need!!!

regards
jx2
Aug 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.