Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/3457-go-to-users-homepage-based-on-session-id/
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]
[!--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
  • 2 weeks later...
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
[!--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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.