Jump to content

[SOLVED] Wierd one here!


ninedoors

Recommended Posts

I'm not sure what is going on in my script but php "seems" to be reading the >= sign as <=.  I'm using it with a login script. Here's it is:

 

<?php
session_start(); // Starts the session.
$ul = $_SESSION['admin'];
if ($ul <= 5) 	{ 
			header("Location: index.php"); // Goes to login page.
			exit(); // Stops the rest of the script.
			}
?>

 

I have checked that $_SESSION['admin'] is set and it is.  $ul = userlevel.  I have this at the top of my page called home.php.  Basically I only want users that have a userlevel of > 5 to be able to access the page. 

 

I try to log in with $_SESSION['admin'] = 9 and it sends me to index.php which isn't right.  When I switch the if statement to

 

<?php
if ($ul >= 5)
?>

 

it allows me to see the page.  Anyone have any ideas.  Just so you know I have echoed $_SESSION['admin'] on this page and it was equal to 9.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/
Share on other sites

if you use this, what happens:

 

 

<?php
  session_start(); // Starts the session.
  $ul = $_SESSION['admin'];
  if ($ul <= 5) {
    die("Not good enough: ".var_export($ul,true));
//    header("Location: index.php"); // Goes to login page.
//    exit(); // Stops the rest of the script.
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.