• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Sub menu in included page PART 2

Hello.
I v build a page loghead.php with sub-menu and i include the selected pages there.

switch($_GET['l'])
{
 case "man":
  $l = "login/main.php";
  break;
 
 case "reg":
  $l = "login/register.php";
  break;
........etc.........
and my sub-menu.
 <li><a href="index.php?p=loghead&l=man">Info</a></li>
 <li><a href="index.php?p=loghead&l=reg" >Register</a></li>

I m trying to include one more page
<li><a href="index.php?p=loghead&l=userinfo" >User Info</a></li>
 but when i try in my switch

case "userinfo":
  $l = "login/userinfo.php?user=$session->username";
  break;

the page is not included.

Any idea???
0
NTGrE
Asked:
NTGrE
  • 4
  • 4
  • 2
1 Solution
 
elodisCommented:

Im not sure if i completely understand what you're asking, but have you tried placing the session variable outsite of the quotes, i.e:

case "userinfo":
  $l = "login/userinfo.php?user=" . $session->username;
  break;


Where are you using your $l variable?  Is it working for your first two switch examples?
0
 
smaccariCommented:
Maybe because you try to add some parameters (user=...)?
The included userinfo.php, as it will be included in the page, can reach variables declared in your page. It can even reach $session->username, so why do you want to pass this as a parameter?

0
 
NTGrEAuthor Commented:
Hi..elodis
1) Yes the first 2 examples working
2)Iv try your code but i geting the same errors as before.
Warning: main(login/userinfo.php?user=tester) [function.main]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\login\loghead.php on line 54

Warning: main() [function.include]: Failed opening 'login/userinfo.php?user=tester' for inclusion (include_path='.;C:\Program Files\xampp\php\pear\') in C:\Program Files\xampp\htdocs\login\loghead.php on line 54

where tester=my login Name & line 54 where i include the pages..
<td align="center"><? include($l); ?></td>

Hi smaccari ..
I m trying to build (modify)a page where registered users can see infos about the acount...
thats why i need the ?user=$session->username
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
elodisCommented:
what does a direct browser call to ../login/userinfo.php?user=tester result in?
0
 
elodisCommented:
sorry...

./

i.e. wherever the page it actually sitting
0
 
NTGrEAuthor Commented:
Sorry i dont understand the question... :((

0
 
elodisCommented:

what happens when you call the page you're trying to include?

From the php errors it looks as if the page doesn't exist - or php doesn't think so anyway.

I was curious what adirect call you your userinfo.php page resulted...

ie

www.yourewebsite.com/login/userinfo.php?user=tester

0
 
NTGrEAuthor Commented:
Hmmmm....
strange...
Fatal error: Call to a member function usernameTaken() on a non-object in C:\Program Files\xampp\htdocs\login\userinfo.php on line 23

where line 23 is
$req_user = trim($_GET['user']);
if(!$req_user || strlen($req_user) == 0 ||
   !eregi("^([0-9a-z])+$", $req_user) ||
   !$database->usernameTaken($req_user)){ <<-----------------------------This !!!!!!
   die("Username not registered");
}

I dont get it...
0
 
smaccariCommented:
What i try to say to you is: as your userinfo.php is included in the main page, you don't have to pass parameters into the querystring, as the userinfo.php will access the same variables you have in the page.
So, in your userinfo.php, just replace this:

$req_user = trim($_GET['user']);

by this:

$req_user = $session->username;
0
 
NTGrEAuthor Commented:
Thnx again smaccari !!!
Working perfect...
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now