TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   else statements (http://www.talkphp.com/absolute-beginners/5528-else-statements.html)

Tim Dobson 07-15-2010 02:55 PM

else statements
 
Im having a bit of trouble figuring the else statements out. I got a login for the site but i cant get it to display logout instead of login if the user is logged in.

Here is what i got:

PHP Code:

<?php
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || 
    (
trim($_SESSION['SESS_MEMBER_ID'])=='')) {
    echo 
"<a href='http://www.sb0t.tentun.co.uk/Login/login-form.php'>Click here</a> to login to your account.<br><a href='http://www.sb0t.tentun.co.uk/Login/register-form.php'>Click here</a> to create an account.'
    
} else {
echo '<a href='http://www.sb0t.tentun.co.uk/Login/logout.php'>Click here</a> to logout.'
}
?>


Where am i goin wrong ? :(

tony 07-15-2010 03:47 PM

it seems that you closed the double quotation with a single one and no semi colon in both echo statements. f

when you write a string you either go "this is a string" or 'this another string'. They have their own advantages.

try this:

php Code:
<?php
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || 
    (trim($_SESSION['SESS_MEMBER_ID'])=='')) {
    echo "<a href='http://www.sb0t.tentun.co.uk/Login/login-form.php'>Click here</a> to login to your account.<br><a href='http://www.sb0t.tentun.co.uk/Login/register-form.php'>Click here</a> to create an account.";
     
} else {
echo '<a href="http://www.sb0t.tentun.co.uk/Login/logout.php">Click here</a> to logout.' ;
}
?>

Tim Dobson 07-16-2010 01:11 AM

ah i see yea the quotes i fixed after i posted it was just ; i forgot about thanks!


All times are GMT. The time now is 01:58 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0