badtimbo Posted July 25, 2008 Share Posted July 25, 2008 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 More sharing options...
mmarif4u Posted July 25, 2008 Share Posted July 25, 2008 Turn your PHP Notice OFF in php.ini file. Link to comment https://forums.phpfreaks.com/topic/116544-php-notice-undefined-variable-userlevel/#findComment-599263 Share on other sites More sharing options...
badtimbo Posted July 25, 2008 Author Share Posted July 25, 2008 The php programmer already turned the notices off and it didn't help. Link to comment https://forums.phpfreaks.com/topic/116544-php-notice-undefined-variable-userlevel/#findComment-599271 Share on other sites More sharing options...
abhikerl Posted July 25, 2008 Share Posted July 25, 2008 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. Link to comment https://forums.phpfreaks.com/topic/116544-php-notice-undefined-variable-userlevel/#findComment-599287 Share on other sites More sharing options...
samshel Posted July 25, 2008 Share Posted July 25, 2008 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. Link to comment https://forums.phpfreaks.com/topic/116544-php-notice-undefined-variable-userlevel/#findComment-599292 Share on other sites More sharing options...
badtimbo Posted July 26, 2008 Author Share Posted July 26, 2008 I'll get the php programmer to check the code. As for the register_globals There on. Could I possible have a problem with the php.ini file I copied it from the old server to the new one? Link to comment https://forums.phpfreaks.com/topic/116544-php-notice-undefined-variable-userlevel/#findComment-599905 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.