Welcome to Geeklog, Anonymous Monday, December 30 2024 @ 03:38 am EST

Geeklog Forums

Show username in staticpages


Grant

Anonymous
I need to show the username and users e-mail in staticpages. How do I do this. The staticpage is 'member only'. I recon its something like this:

Text Formatted Code

return 'hello $user, your email is $email';

 


Thanks in advance.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The name of the current user is available through the $_USER array:
Text Formatted Code
return "Hello, {$_USER['username']}!";
 
It's empty for anonymous users, though.

The email address is not stored in $_USER. You would have to get it from the database.

bye, Dirk
 Quote

Grant

Anonymous
Thanks.

How would I get the e-mail though? I'm not really familiar with fetching MySQL information.. Eek!
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by Grant: How would I get the e-mail though?

Something like
Text Formatted Code
$email = DB_getItem ($_TABLES['users'], 'email', "uid = {$_USER['uid']}");
 
would return the email address of the current user (again, that won't work for anonymous users).

bye, Dirk
 Quote

Grant

Anonymous
Quote by Dirk:
Text Formatted Code
$email = DB_getItem ($_TABLES['users'], 'email', "uid = {$_USER['uid']}");

 

bye, Dirk


If i put that in, and enter.. lets say

Text Formatted Code

return 'your email is £email';

 


its doesnt do anything but print 'your email is $email' on the page... more help please Wink
 Quote

Status: offline

inspiremin

Forum User
Regular Poster
Registered: 01/07/04
Posts: 111
Think in terms of US Dollars "$" not "£"
www.Scripturetoolkit.com www.inSPIREministries.com
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Assuming the Pound symbol was a typo: You have to enclose the string in double quotes, not single quotes.

bye, Dirk
 Quote

Grant

Anonymous
Thanks. Your assumtion was correct, it was a typo Wink It works now! Silly mistake...
 Quote

All times are EST. The time is now 03:38 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content