Jump to content


Photo

Go to User's Homepage Based on Session ID


  • Please log in to reply
6 replies to this topic

#1 Stone Gossard

Stone Gossard
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 February 2006 - 03:30 PM

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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 17 February 2006 - 03:34 PM

Something like the following:
<?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;

?>


#3 Stone Gossard

Stone Gossard
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 February 2006 - 04:41 PM

[!--quoteo(post=346767:date=Feb 17 2006, 10:34 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Feb 17 2006, 10:34 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Something like the following:
<?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;

?>
[/quote]

Top Class.

Thanks a Mill.

Stone


#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 18 February 2006 - 02:40 PM

No problem! I have code similar to that with a forum I am currently developing.

#5 Stone Gossard

Stone Gossard
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 02 March 2006 - 06:38 PM

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

#6 willpower

willpower
  • Members
  • PipPipPip
  • Advanced Member
  • 296 posts
  • LocationWarrington, Cheshire, UK

Posted 02 March 2006 - 07:54 PM

I'd suggest that you have added a whitespace to the end of the url before closing the quotation marks

will
Wait...I've got it...Bollocks, it's gone again!

If at first you don't succeed....stop using ASP and get onto PHP

#7 Stone Gossard

Stone Gossard
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 04 March 2006 - 12:21 PM

[!--quoteo(post=351075:date=Mar 2 2006, 02:54 PM:name=willpower)--][div class=\'quotetop\']QUOTE(willpower @ Mar 2 2006, 02:54 PM) View Post[/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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users