Thanks dalecosp!
I don't think it's the actual code, as I haven't had any problems with it on the original server, and it's the standard Dreamweaver login code, but here it is (the important bits anyway)...
<?php require_once('../Connections/ernact.php'); ?>
<?php
if (isset($_POST['pwd'])) { $_POST['pwd'] = sha1($_POST['pwd']); }
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['Username'])) {
$loginUsername=$_POST['Username'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "Access_Level";
$MM_redirectLoginSuccess = "admin.php";
$MM_redirectLoginFailed = "loginfail.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_ernact, $ernact);
$LoginRS__query=sprintf("SELECT Username, Region_Id, Password, Access_Level FROM users WHERE Username=%s AND Password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $ernact) or die(mysql_error());
// fl added to store the Region_id
$row = mysql_fetch_array( $LoginRS );
$_SESSION['Region_Id'] = $row['Region_Id'];
// end fl
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'Access_Level');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Connected Mobile Community - Connected Mobile Communities - Administrator Login</title>
</head>
<body>
<div id="wrapper">
<form id="login" name="login" method="POST" action="<?php echo $loginFormAction; ?>">
<label>Username</label><br />
<input type="text" name="Username" id="Username" />
<br />
<br />
<label>Password</label><br />
<input type="password" name="Password" id="Password" />
<br />
<br />
<input type="submit" name="Login" id="Login" value="Login" />
</form>
</div>
</body>
</html>