SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Isset

  1. #1
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Isset

    Can anyone tell me why this doesn't work?
    PHP Code:
    <?php IF(!IsSet($admin)) { print("<a href=\"login.php\" onMouseOver=\"window.status='';return true\" onMouseOut=\"window.status='';return true\">"); } ?><FONT size="1" color="#1D2868">5</FONT><?php IF(!IsSet($admin)) { print("</a>"); } ?>
    I need it so if someone is logged in, it won't show that. I already have it so that ?admin will be next to the url after someone is logged in, so $admin should exist, but it doesn't.
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want it to show that if an admin is logged in, then remove the ! from IF(!IsSet($admin)). Also, it would be better IMO to just use ?admin=1 and then if($admin) instead of ?admin and what you current have.

    You should definitely check for authorization even if ?admin=1 is appended to the URL--nothing is stopping anyone from just adding that and gaining admin access.

  3. #3
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay thanks.

    I am going to check, but I was planning on only running sessions if the admin variable is there, so it doesn't slow down most people. I'm not sure if it would be worth it though. Would sessions slow the site down at all?
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jesus christ that is ugly code.

    1. Put it on multiple lines.

    2.The if statement braces can span HTML tags, so you don't need two if statements.

    3. Keep HTML and PHP lowercase.

  5. #5
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the capital letters are because I copied that code from php.net to make sure I wasn't doing anything wrong.

    anyone know whether sessions makes a big speed difference
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  6. #6
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On all but the most highly-trafficked sites, sessions won't make a noticeable speed different.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •