Jump to content

Archived

This topic is now archived and is closed to further replies.

Stone Gossard

Go to User's Homepage Based on Session ID

Recommended Posts

I want to be able to have a hyperlink at the end of a page which can be accessed from a number of pages. This hyperlink should bring the user back to a specified homepage based on their access level, e.g. administrator is brought back to admin_homepage.php and registered user is brought back to reg_user_homepage.php.

I have sessions working on my site and i know this isn't too difficult but just now sure how to do the hyperlink thing.

Appreciate it.

Stone

Share this post


Link to post
Share on other sites
Something like the following:
[code]<?php

session_start();

$link = "<a href=";

if($_SESSION['access_lvl'] == "Admin")
{
    $link .= "admin_homepage.php";
}
elseif($_SESSION['access_lvl'] == "User")
{
    $link .= "reg_user_homepage.php";
}

$link .= "\">Home</a>";

echo $link;

?>[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=346767:date=Feb 17 2006, 10:34 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Feb 17 2006, 10:34 AM) [snapback]346767[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Something like the following:
[code]<?php

session_start();

$link = "<a href=";

if($_SESSION['access_lvl'] == "Admin")
{
    $link .= "admin_homepage.php";
}
elseif($_SESSION['access_lvl'] == "User")
{
    $link .= "reg_user_homepage.php";
}

$link .= "\">Home</a>";

echo $link;

?>[/code]
[/quote]

Top Class.

Thanks a Mill.

Stone

Share this post


Link to post
Share on other sites
No problem! I have code similar to that with a forum I am currently developing.

Share this post


Link to post
Share on other sites
Thanks for that code and i've tried it ok, and it does redirect to the users homepage based on their access level but it keeps adding

code:

reg_user_page.php%22

Why does it add "%22" to the end of the URL? That's what causing it not to find the page.

Stone

Share this post


Link to post
Share on other sites
I'd suggest that you have added a whitespace to the end of the url before closing the quotation marks

will

Share this post


Link to post
Share on other sites
[!--quoteo(post=351075:date=Mar 2 2006, 02:54 PM:name=willpower)--][div class=\'quotetop\']QUOTE(willpower @ Mar 2 2006, 02:54 PM) [snapback]351075[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I'd suggest that you have added a whitespace to the end of the url before closing the quotation marks

will
[/quote]
Will,

I had an extra inverted comma, thanks.

Stone

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.