Home button help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Raith
Forum Newbie
Posts: 2
Joined: Tue Mar 31, 2009 12:50 am

Home button help

Post 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.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Home button help

Post 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>.
Raith
Forum Newbie
Posts: 2
Joined: Tue Mar 31, 2009 12:50 am

Re: Home button help

Post 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.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Home button help

Post 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> 
 
Post Reply