0

I am getting an error in the code below, session_register('adminuser') seems to be the cause. How do I solve this?

// username and password sent from Form
$adminuser=mysql_real_escape_string($_POST['adminuser']); 
$adminpassword=mysql_real_escape_string($_POST['adminpassword']); 
$gpassword=md5($adminpassword); // Encrypted Password
$sql="SELECT id FROM admin WHERE adminuser='$adminuser' and adminpassword='$gpassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

// If result matched $username and $password, table row must be 1 row
if($count==1)
{
    session_register('adminuser'); <--- this code causes error
    header("location:index.php");
}
else
{
    header("location:login.php?error=error");
Nunser
  • 4,494
  • 8
  • 23
  • 35

1 Answers1

4

The session_register() function has been removed from PHP 5.4.

There is no need to register a session variable. You can simply assign a value when required:

$_SESSION['adminuser'] = 'John';

From the Manual:

This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

MrCode
  • 61,589
  • 10
  • 82
  • 110