Help with Using sessions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boorama
    New Member
    • Aug 2007
    • 1

    #1

    Help with Using sessions

    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($_SESS ION['valid_user'])){






    echo '<strong>Your appointment reference number is: '.$_SESSION['valid_user'].' <br />';




    $result = mysql_query("SE LECT 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_arr ay( $result );
    // Print out the contents of the entry

    echo "Name: ".$row['ref_num'];
    echo " Age: ".$row['fname'];



    }

    mysql_close();


    ?>
  • jx2
    New Member
    • Feb 2007
    • 228

    #2
    u need to register a session variable

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

    this code is all you need!!!

    regards
    jx2

    Comment

    Working...