Welcome to Geeklog Sunday, May 31 2020 @ 10:27 am EDT

Geeklog Forums

staticpages and php problem

Status: offline


Forum User
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 Smile


Status: offline


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

Status: offline


Forum User
Registered: 15/04/04
Posts: 7
$_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


right on top of the code i posted ?

All times are EDT. The time is now 10:27 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