Link to home
Start Free TrialLog in
Avatar of NTGrE
NTGrE

asked on

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???
Avatar of elodis
elodis


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?
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?

Avatar of NTGrE

ASKER

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
what does a direct browser call to ../login/userinfo.php?user=tester result in?
sorry...

./

i.e. wherever the page it actually sitting
Avatar of NTGrE

ASKER

Sorry i dont understand the question... :((


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

Avatar of NTGrE

ASKER

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...
ASKER CERTIFIED SOLUTION
Avatar of smaccari
smaccari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NTGrE

ASKER

Thnx again smaccari !!!
Working perfect...