Switch $id session variable
:confused:
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=
:cry:
Re: Switch $id session variable
is userinfo.php in the same directory as the index.php?
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.