Jump to content

PHP Notice: Undefined variable: userlevel


badtimbo

Recommended Posts

Our server mainboard is down and we are setting up our site to run on another machine. Our site was running fine on it but when we put it on the other machine we got this. PHP Notice: Undefined variable: userLevel in C:\webpub\nameofsite\login.php on line 2 PHP Notice: Undefined variable: userLevel in C:\webpub\nameofsite\login.php on line 9 PHP Notice: Undefined variable: mode in C:\webpub\nameofsite\login.php on line 9 PHP Notice: Undefined variable: mode in C:\webpub\nameofsite\login.php on line 28 PHP Notice: Undefined variable: mode in C:\webpub\nameofsite\login.php on line 45 PHP Notice: Undefined variable: mode in C:\webpub\nameofsite\login.php on line 61. Note* the words nameofsite has been inserted for the actual name. Is it possible that the php.ini file is messed up? I copied the exact one out of the php directory so its the same.

 

We set the directories up just like on the original server machine. Here is our code.

 

 

<?PHP

if ($userLevel == 'admin' AND $mode == 'admin_login')

  {

  print "

      <BR><font size='+1'><b>Admin Special Login</b></font>

<BR><i>Logging in this way requires no password and will show no user activity on the account.</i><BR><BR>

";

}

elseif ($userLevel != 'admin' AND $mode == 'admin_login')

  { 

  print "

      <font size='+1'><b>Admin Special Login</b></font>

<BR><BR>

";

REQUIRE("C:\webpub\nameofsite\includes\alerts\alert_error_top.php");

  print "

You must be a currently logged in site admin to use this feature.

";

REQUIRE("C:\webpub\nameofsite\includes\alerts\alert_bottom.php");

$show_brs=no;

include('C:\webpub\nameofsite\bottomhtml.php');

die;

}

?>

 

<form action='http://www.nameofsite/process_login.php' method='post'>

<?PHP

if ($mode != 'admin_login')

  {

  print "

<sup><a href='http://www.nameofsite/signup.php'>No Account? Sign Up!</a></sup>

      ";

  }

?>

<table cellpadding='3'>

<tr bgcolor='CCCCCC'>

  <td>

<b>Username:</b>

</td>

<td>

<input type='text' name='submitname' maxlength='20' size='15'>

</td>

</tr>

<?PHP

if ($mode != 'admin_login')

  {

  print "

<tr bgcolor='CCCCCC'>

  <td>

<b>Password:</b>

</td>

<td>

<input type='password' name='submitpass' maxlength='36' size='15'>

</td>

</tr>

      ";

  }

?>

</table>

<?PHP

if ($mode == 'admin_login')

  {

  print "

<INPUT TYPE='hidden' NAME='mode' VALUE='admin_login'>

      ";

  }

?>

<input type=submit style=color:white;background-color:deepskyblue;font-weight:bold; value='Login Now'>

<?PHP

 

//<br><a href='C:\webpub\nameofsite\passwords.php'>[Lost Pass?]</a>?>

</form>

 

 

We are running these programs

 

Windows XP Pro

php-5.2.6

mysql-5.1.26

quick & easy web server

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/116544-php-notice-undefined-variable-userlevel/
Share on other sites

I had a problem a bit similar like that. I had an error "undefined variable valid_id".

 

if($_SESSION["valid_id"])=="")

{

  echo "unauthorized acess";

}

 

`````````````````````

 

so I changed it to

 

if (!isset($_SESSION['valid_id']))

{

  echo "unauthorized acess";

}

 

and this solve out the error.

are the server settings for old and new ones same ??

 

check things like register_globals.

 

your code below suggests on your old server register_globals in php.ini to be "On", but it can be "Off" on new server.

 

<?PHP
if ($userLevel == 'admin' AND $mode == 'admin_login')

 

assumption $userLevel is coming from a submitted form.

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.