Page 1 of 1

Home button help

Posted: Tue Mar 31, 2009 12:56 am
by Raith
Hi all, I'm new to the forums and I apologize if this has been a posted topic before but I wasn't quite sure how to look for it. I'm new to PHP and its been forever since I've done HTML and I'm just starting to get back into it all with designing of a website.

I was just looking for some basic help that I wasn't quite sure how to do...

The way that I'm building this site is so that there can be users and different pages, etc, you know the drill, and my problem was when I was doing the designing I wasn't quite sure how to put in a "Home" button that would take the person to the home screen of the website when logged out and to take them to their account when logged in. I haven't set up the user database yet but this was just something that I was annoying me because I haven't been able to figure it out.

I've come to one of two conclusions... that once a user logs in, there is all new web pages that I need to put in the database (which I doubt) or its just an alternate command, in which case I need to know how to link it all together.

Thanks for any help.

Re: Home button help

Posted: Tue Mar 31, 2009 1:07 am
by papa
An easy way would be to for example display a different menu depending on if the user has logged in or not:

Code: Select all

 
if(isset($_SESSION['user'])) {
include "user_menu.php";
} else {
include "menu.php";
}
 
Or just change the include to a <a href>.

Re: Home button help

Posted: Tue Mar 31, 2009 12:53 pm
by Raith
Hey, thanks very much for your quick answer. Just to further get explanation though... your code is saying that if the user is
logged in then the command is to take them to a user menu, right?

Well instead of a different menu loading, is it possible to just have the "Home" button redirect them to their profile instead of the main page? I think I'm going to aim at keeping the menu pretty consistent throughout the website and putting user options on the user page.

Re: Home button help

Posted: Wed Apr 01, 2009 2:10 am
by papa
Depends on how your menu looks like, but you could do something like:

Code: Select all

 
if(isset($_SESSION['user'])) {
$home = "userpage.php";
} else {
$home = "index.php";
}
 
//My Menu
echo "<a href=\"$home\">Home</a> | ";
?>
<a href="#">Button2</a> | <a href="#">Button3</a> | <a href="#">Button4</a>