Old 05-11-2008   #1 (permalink)
Registered User
 

Join Date: May 2008
Posts: 3

Member Tutorial: Taking it further.

Hey,

I completed the membership tutorial and have it fully working on my website. There is one thing that I have always wanted but just couldn't find out how to do so that it would work properly. That is displaying a message in the navigation bar for users while logged in, but something different when not. For example:

Welcome Trueskool, Control Panel | Logout <-- When logged into the script

Welcome Guest! Please Login or Register <-- When not logged in


I was able to put this code together, which was showing the logged in message where ever I put the code, but I need to take if further and possibly do some sort of IF Statement, along with SESSION.

PHP Code:
<?php
echo "
<p>Welcome '.$_SESSION['s_username'].'! <a href="
http://example.com/member.php">Control Panel</a> | <a  href="http://example.com/logout.php">Logout</a></p>
";
?>
NOTE: I'm not a coder, I plan to start learning PHP properly within the next few months.

Any help would be awesome!

Thanks,

Last edited by Trueskool; 05-11-2008 at 01:47 PM.
Trueskool is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 05-11-2008   #2 (permalink)
Registered User
 

Join Date: May 2008
Location: Sheffield, United Kingdom
Posts: 2

This is kindof like the code I created for that.

PHP Code:
<?php
if($_SESSION['s_logged_n'] == 'true'){
include 
'menulog.php';
?>
<?php
} else {
include 
'menuunlog.php';
}
?>
That means that anyone who is logged into the page will see menulog.php and anyone who isnt will see menuunlog.php

This is the easiest way ive found to create dynamic menu systems like that and it also means that you can quiclky adjust your menus without trying to find the right section of code.

Alternativly if you feel like doing it your way and not using includes paste this code into your site =)

PHP Code:
<?php
if($_SESSION['s_logged_n'] == 'true'){
echo 
"
<p>Welcome '.$_SESSION['s_username'].'! <a href='http://example.com/member.php'>Control Panel</a> | <a  href='http://example.com/logout.php'>Logout</a></p>
"
;
?>
<?php
} else {
echo 
"
<p>Welcome Guest! Please Login or Register</p>
"
;
}
?>

Last edited by whelpton; 05-11-2008 at 06:26 PM. Reason: Better answer
whelpton is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Member Tutorial: If user is logged in. Trueskool HTML / PHP / ASP / JS 1 08-07-2008 04:10 PM
Member Tutorial: problems with register jull HTML / PHP / ASP / JS 0 05-20-2008 11:18 AM
Taking a hard drive apart DrkDeath General Discussions 3 06-05-2006 12:24 AM
I feel like taking a life Silent Walker General Discussions 1 12-30-2005 08:55 PM


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT