I need help updating this script please

Hi
My web hosting company has updated their PHP and as a consequence my login script has stopped working. From what I have found out the session register() is no longer used and that $_SESSION should be used instead.

Can anyone give me some ideas on how to change the script so I can get this working again as I can’t log in to my website otherwise.

Thank you in advance.

Phil
[php]<?php require_once('../Connections/phcleani_forms.php'); ?>

<?php mysql_select_db($database_phcleani_forms, $phcleani_forms); $query_Recordset1 = "SELECT * FROM applicants"; $Recordset1 = mysql_query($query_Recordset1, $phcleani_forms) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <?php // *** Validate request to login to this site. session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['name'])) { $loginUsername=$_POST['name']; $password=$_POST['email']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "success.php"; $MM_redirectLoginFailed = "index.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_phcleani_forms, $phcleani_forms); $LoginRS__query=sprintf("SELECT username, password FROM applicants WHERE username='%s' AND password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $phcleani_forms) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Untitled Document

 

Username
Email
Login

 

<?php mysql_free_result($Recordset1); ?> [/php]

Just use $_SESSION as a normal array

Which version have they upgraded to? They have hopefully removed all the mysql_ functions as well (removed in PHP7)

Hi
My hosting company is using PHP 5.6.30

Can you give me an idea of how to use a $_SESSION as a normal array. I’m sorry, I am a complete newbie and don’t have any previous programming experience.

Many thanks

Phil

The entire script is obsolete and has very dangerous code. You need to trash the script and rewrite it from the ground up using PDO with prepared statements. There is no fixing this code.

Sponsor our Newsletter | Privacy Policy | Terms of Service