Code: Select all
<?php require($_SERVER['DOCUMENT_ROOT'].'/Connections/pwdbase.php'); ?>
<?php
// *** Validate request to login to this site.
// If session has not been started, start session.
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 = "";
$MM_redirectLoginSuccess = $_GET['page'];
$MM_redirectLoginFailed= "test.html";
$MM_redirecttoReferrer = true;
mysql_select_db($database_pwdbase, $pwdbase);
$LoginRS__query=sprintf("SELECT user, pass, page FROM main WHERE user='%s' AND pass='%s'",get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $pwdbase) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//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 );
}
}
?>