TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-15-2010, 02:55 PM   #1 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default 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 ? :(
Tim Dobson is offline  
Reply With Quote
Old 07-15-2010, 03:47 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

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.' ;
}
?>
tony is offline  
Reply With Quote
The Following User Says Thank You to tony For This Useful Post:
Tim Dobson (07-16-2010)
Old 07-16-2010, 01:11 AM   #3 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default

ah i see yea the quotes i fixed after i posted it was just ; i forgot about thanks!
Tim Dobson is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB 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
TalkPHP Project Kalle TalkPHP Developer Team 293 12-19-2008 02:26 AM
IF statements with XML files Magpie Parser buildakicker General 1 10-02-2008 10:23 PM
CSS and if statements delayedinsanity XHTML, HTML, CSS 2 07-10-2008 11:20 PM
having nested mysql_fetch_assoc statements sarmenhb Absolute Beginners 5 06-13-2008 04:12 PM
Prepared statements delayedinsanity Advanced PHP Programming 0 04-28-2008 06:15 AM


All times are GMT. The time now is 08:43 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design