Dreamweaver 8 - I can't log in to admin pages. MYSQL table, DB all look fine. Here is the login code:
<?php require_once('../Connections/vvfa_data.php'); ?>
<?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'];
}
function Encrypt($string) {//hash then encrypt a string
$crypted = crypt(md5($string), md5($string));
return $crypted;
}
if (isset($POST['login'])) {
$loginUsername=$POST['login'];
$password=Encrypt ($_POST['password']);
$MM_fldUserAuthorization = "level";
$MM_redirectLoginSuccess = "default.php";
$MM_redirectLoginFailed = "test-login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_vvfa_data, $vvfa_data);
$LoginRS__query=sprintf("SELECT username, password, level FROM admin WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
//$LoginRS = mysql_query($LoginRSquery, $vvfa_data) or die(mysql_error());
$LoginRS = mysql_query($LoginRSquery, $vvfa_data) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'level');
//$loginStrGroup = mysql_result($LoginRS,0,'level');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
The connection file is fine but I always get dumped out ($MM_redirectLoginFailed) even though the username/password are right. How can I fix this?
Thanks for you consideration,
Gary