OK so I wrote this login code a while ago and it has been working great until recently.
I use sessions to hold the login information. Trouble is suddenly I get this error
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
If I simply enter the username/password again, it connects fine. but I always have to log in twice now. and I want to make sure my code is working right.
I do have a php.ini with "register_globals=on" and it doesnt matter.
Here is my code, maybe you can suggest a better way?
//Convert formpass to md5
$securepass=md5($_POST['formpass']);
//Convert username
$uname = $_POST['uname'];
//Connect to the database
include("inc/db.php");
//Get See if there are any matches for the login used
$sql="###SELECT STATEMENT###";
$result = mysql_query($sql,$db);
$myrow = mysql_fetch_assoc($result) or die ("Index.php: There was an Error with the Database, ".mysql_error()."\n");;
$row_count = mysql_num_rows($result);
//Check if login retuned results
if($row_count > 0)
{
//Login was sucsessful
//register the userid and Admin level
$userid=$myrow["username"];
$adminaccess=$myrow["admin"];
session_register("userid");
session_register("adminaccess");
//Update last access
$logindate = date("Y-m-d");
$result=mysql_query("UPDATE billuser SET lastaccess='$logindate' WHERE username='$uname'") or die ("Failed to enter Last Login, ".mysql_error()."\n");;
//Inlude main page
include("page.php");
}else{ //password does not match,
//display error
echo "<br><br><center>Incorrect Login, try again</center>";
include("login.htm"); //display login form
exit(); //stop
}
my PHP version is 4.3.11
thanks in advance!