Results 1 to 3 of 3

Thread: Switch $id session variable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2004
    Location
    UK
    Posts
    119

    Switch $id session variable



    on a site im doing, I'm building a login script, its working fine however i have included it into a mini table under the navigation, the problem i having is I use the switch function to load the pages in the main area of the page and it works perfectly for all other links but not this one

    when the user is logged in, this is echo'ed

    Code:
    echo "<a href='index.php?id=My Account'>My Account</a><br>";
    and the code in the switch function is

    Code:
    case "My Account": include ('userinfo.php?user=$session->username');
    the variable $session->username is what returns the users name so say I was logged in, my username is Shadows, it would look like this

    Code:
    userinfo.php?user=Shadows
    however, this is not working

    Code:
    Warning: main(userinfo.php?user=$session->username): failed to open stream: No such file or directory in /home/shadows/public_html/1.0/index.php on line 129
    any idea's on how I can get $session->username to return the logged in name onto the end of the link userinfo.php?user=


  2. #2
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909

    Re: Switch $id session variable

    is userinfo.php in the same directory as the index.php?

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Switch $id session variable

    Inclusion without a http: prefix works on a file level, so this is actually looking for a file called "userinfo.php?user=$session->username". (Not even a file called "userinfo.php?user=hugo", as substitution is only done in double-quoted strings.)

    If you simply include userinfo.php, the session variable is available there, if it is global.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width