Welcome to Geeklog Thursday, September 19 2019 @ 03:17 pm EDT

Geeklog Forums

staticpages and php problem


Status: offline

sornok

Forum User
Newbie
Registered: 04/03/04
Posts: 9
I am trying to do the following on a static page

PHP Formatted Code
?><?php if ($_USER['uid']>=2) {echo $_USER['uid']; echo '<a href="/usersettings.php?mode=edit">';} else {echo $_USER['uid']; echo '<a href="/users.php?mode=new">';}?>press here</a>
 


what I want to do is to check if the current user is a member or not and create the appropriate link for him , ie if its a member to create a link to edit his/her profile and if its a guest to create a link to go to the registration page

the page is centerblock and it is at the top of the page - homepage only - not wrapped in a block

my first question is, what is the value of $_USER['uid'] when a user is not logged in ? although I use an echo to type it, this echo does nothing...

the main problem is that this piece of code works only when it is not shown as a centerblock (as a simple static page) and always with the problem of my first question

if there is another way to do all this i would be curious to know

thx

Status: offline

Blaine

Forum User
Full Member
Registered: 16/07/02
Posts: 1233
Location:Canada
For anonymous users $_USER['uid'] is == 1
Geeklog components by PortalParts -- www.portalparts.com

Status: offline

diego

Forum User
Newbie
Registered: 15/04/04
Posts: 7
caffeinated
$_USER is a global variable, so to used it, first you have to check if it's declared on the code, like:
global $_USER;
[]'s diego

sornok

Anonymous
right on top of the code i posted ?

All times are EDT. The time is now 03:17 pm.

  • 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