Log in script no longer working following upgrade to PHP5

Hi Folks,

My server has just been upgraded from PHP4 to PHP 5 and as a result the login scripts don’t work any longer. Can anyone let me know why that may have happened?

I have checked the database connections and everything seems fine but when a user submits the correct (or incorrect details) nothing at all happens.

If it helps, here is some code:


<?php session_start(); ?>
<?php require_once('../Connections/con_dcam.php'); ?>
<?php
// Login & Set Session - Recordset
$myUsername_rsLogin = "0";
if (isset($HTTP_POST_VARS['username'])) {
  $myUsername_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['username'] : addslashes($HTTP_POST_VARS['username']);
}
$myPassword_rsLogin = "0";
if (isset($HTTP_POST_VARS['password'])) {
  $myPassword_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['password'] : addslashes($HTTP_POST_VARS['password']);
}
mysql_select_db($database_con_dcam, $con_dcam);
// Verify Login is correct
$query_rsLogin = sprintf("SELECT username, password FROM `access` WHERE username = '%s' AND password = '%s'", $myUsername_rsLogin,$myPassword_rsLogin);
$rsLogin = mysql_query($query_rsLogin, $con_dcam) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);

// Login & Set Session - Main
if($HTTP_POST_VARS['action']=="login"){
	if($totalRows_rsLogin==0){
		$errorMessage = "";
		mysql_free_result($rsLogin);
	} else {
		mysql_free_result($rsLogin);
		session_register("dcamadmin");
		$HTTP_SESSION_VARS['dcamadmin'] = $HTTP_POST_VARS['username'];
		header("Location: welcome.php");
	}
}
?>



cheers

Dave

$HTTP_POST_VARS is deprecated. Use $_POST instead.
So is $HTTP_SESSION_VARS. Use $_SESSION instead.

Also, sessions are closed when any output is sent to the browser. This happens immediately after you close the first PHP tag with ?> and hit the carriage return - that goes into output. Get rid of the unneeded opening and closing of the php tags at script start.

Perfect thanks.
Done all of that and it works like a swiss watch again.