Php error help

A few years ago a took over the hosting and the website I did not build. It also uses a bespoke CMS. It has been working correctly since then, but they are now getting the below error when logging in.

 Fatal error: Call to undefined function session_register() in /home/lpdgco/public_html/resources/check_login.php on line 119

None of the files have changed so I don't understand what is the problem?

Below is the code of the "check_login.php" page...

<?



include "mysql.inc.php";



// Convert to simple variables

$username = $_POST['login_username'];

$password = $_POST['login_password'];

$ref_url = $HTTP_REFERER;



if((!$username) || (!$password)){



	header("Location: ../index.php");

	exit();



}



// check if the persons given the correct info

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;



  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;    

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}



$LoginRS__query=sprintf("SELECT * FROM users WHERE username=%s AND password=%s AND activated='yes'",

GetSQLValueString($username, "text"), GetSQLValueString($password, "text"));

$sql = mysql_query($LoginRS__query) or die(mysql_error());





$login_check = mysql_num_rows($sql);



if($login_check > 0){

	while($row = @mysql_fetch_array($sql)){

	foreach( $row AS $key => $val ){

		$$key = stripslashes( $val );



	}



		// Register some session variables!

		session_register('user_id');

		$_SESSION['user_id'] = $user_id;

		session_register('username');

		$_SESSION['username'] = $username;

		session_register('password');

		$_SESSION['password'] = $password;

		session_register('email');

		$_SESSION['email'] = $email;

		session_register('user_level');

		$_SESSION['user_level'] = $user_level;

		session_register('activated');

		$_SESSION['activated'] = $activated;

		session_register('has_webmail');

		$_SESSION['has_webmail'] = $has_webmail;

		session_register('webmail_addy');

		$_SESSION['webmail_addy'] = $webmail_addy;

		session_register('webmail_pass');

		$_SESSION['webmail_pass'] = $webmail_pass;



		// if user asked to remember them, do it!!

		if(isset($_POST['remember'])){

		  setcookie("cookname", $_SESSION['username'], time()+60*60*24*100, "/");

		  setcookie("cookpass", $_SESSION['password'], time()+60*60*24*100, "/");

		}



		// Log this login with date and time

			//lets create the query

			$sql = mysql_query("UPDATE users SET last_login = now() WHERE userid = '$user_id'");





		// check the referer URL, if it doesn't exist then just show them to the index page

		if ($HTTP_REFERER == ""){



			// url isn't set so send them to the index page

			header("Location: ../index.php");



		}else{



			// We have a referer url so send them there!

			header("Location: $HTTP_REFERER");



		}



	}



} else {



		header("Location: ../index.php");



}



?>

Open in new window

petewinterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ArgentiCommented:
Hi

Please read Here...

Check your PHP version. "This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0." Maybe you've automatically upgraded your PHP installation.

Cheers!
0
PortletPaulfreelancerCommented:
session_register()
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
http://php.net/manual/en/function.session-register.php

(i.e. I suspect your hosting provider has recently upgraded the PHP version)

You could ask your provider for access to an older PHP version perhaps?

Otherwise I think you are looking at a need to revise the PHP scripts
e.g.
http://stackoverflow.com/questions/3682615/how-to-fix-the-session-register-deprecated-problem
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulfreelancerCommented:
regarding script changes, this is the effect:

E-E PAQ (by: Ray_Paseur)
Make sure all of your scripts use this at the very top before any output at all:

session_start();

Then use the $_SESSION array just like any other associative array.  It is "superglobal" so it can be accessed in any variable scope or namespace.

<?php
// ALWAYS START THE SESSION ON EVERY PAGE
session_start();

// NOW BACK TO THE OTHER STUFF
header('Content-Type: text/html; charset=utf-8');
error_reporting(E_ALL);
include "./common_db.inc";
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_25270685.html#a27275287
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

petewinterAuthor Commented:
Yes your correct. Many thanks for the help!
0
PortletPaulfreelancerCommented:
thanks - best of luck with this - been caught myself by providers just upping stuff with little or no warning :)
0
petewinterAuthor Commented:
Many thanks. It will be a good reason for my client to update their website as it has not be touched for years!!!
0
PortletPaulfreelancerCommented:
hooray! yes a very good reason - and there are so many good options these days as well.

even more good luck to you ;)

Cheers, Paul
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.