Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 03:25:35 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155541 Posts in 21713 Topics by 7737 Members
Latest Member: simpleguy3
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: I am clearly incredibly dumb but...  (Read 516 times)
david doc watson

Offline Offline

Posts: 49



« on: February 20, 2011, 02:54:21 PM »

I want to create a simple Droplet and can't work out the Syntax.

I simply want to show the logged in user's name on the page. I've worked out that the variable I need is:
$_SESSION['USERNAME'].  But what exactly to I put into the drplete box?

return $_SESSION['USERNAME']

or something else.

Thanks
Logged
NorHei
Forum administrator
*****
Offline Offline

Posts: 485


WWW
« Reply #1 on: February 20, 2011, 04:42:53 PM »

Hmm, if variable is the right one i guess you forgot the ";" at the end  grin

Code:
return $_SESSION['USERNAME'];

I would extend this a little bit.
Code:
if (isset($_SESSION['USERNAME'])) {return $_SESSION['USERNAME'];}
else {return 'Guest';}


As a session is only created if a user is logged in, you wil get an error messabe if the variable does not exist.
Logged

It is easier to change the specification to fit the program than vice versa.
david doc watson

Offline Offline

Posts: 49



« Reply #2 on: February 21, 2011, 10:13:34 AM »

Genius,

Thank you so much, the semi-colon did the trick.

Thanks for the idea about the non-logged in user - in this case the page is within the 'client area' but your code will be really useful in the future.

Thanks
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!