Jump to content

Help fixing this


Recommended Posts

PHP Fatal error:  Call to undefined function session_register() - From error log this is for a login page.

$mode = $_GET['mode'];




$result = mysql_query("SELECT * FROM user WHERE username='" . $myusername . "' and password='" . $encrypted_mypassword . "'",$db);

if(!$result) { echo mysql_error(); }

else {

	$count=mysql_num_rows($result);				// If result matched $myusername and $mypassword, table row must be 1 row

	if($count == 1) {

		$row = mysql_fetch_assoc($result);		// Register $myusername, $mypassword



		$_SESSION['user_id'] = $row['username'];

		$_SESSION['user_type'] = $row['usertype'];

		$_SESSION['logged_in'] = TRUE;


	} else {

		if($mode == "new") {


		} else {





I believe this is because of php version any advise on changing the code to work with newer versions ?

Link to comment
Share on other sites

@dsonesuk  Thank you for that i have already implemented that but for some reason when i try to login it doesn't login but display this error



        $error = $_GET["error"];

        if ($error == "wrong") {	echo "Wrong Username and Password entered. Please try again!"; } 

        else if ($error == "nouser") {	echo "You are trying to access a secured page. Please provide your Username and Password to continue."; } 

        else {	echo "Please login to proceed."; }


The above php code is in the login page.

Link to comment
Share on other sites

Session_register hasn't been there since PHP 5.4:



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

Your code won't work in PHP 7 either, because you're using the old mysql extension, which is not in PHP 7.  You need to update that to something modern, and you need to use prepared statements so that your code isn't vulnerable to SQL injection attacks.  You should also consider using PHP's built-in password hashing functions, md5 hasn't been considered cryptographically secure since the mid 90s.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...