Here is the code.
<?php require_once('../Connections/fabricdesign.php'); ?>
<?php
if (isset($_POST['pwd'])) {$_POST['pwd'] = sha1($_POST['pwd']);}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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['pwd'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "success.php";
$MM_redirectLoginFailed = "loginfail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_fabricdesign, $fabricdesign);
$LoginRS__query=sprintf("SELECT username, pwd FROM users WHERE username=%s AND pwd=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $fabricdesign) 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']) && false) {
$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>Untitled Document</title>
<link href="../css/basiclayout.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header"><a href="index.html"><img src="../images/logo.jpg" width="207" height="69" alt="Logo" /></a><a href="index.html"><img src="../images/link_images/home.jpg" alt="Home" width="48" height="10" class="navlink" /></a><a href="fabric.html"><img src="../images/link_images/fabric.jpg" alt="Fabric" width="65" height="10" class="navlink" /></a><a href="buy.html"><img src="../images/link_images/buy.jpg" alt="Buy" width="34" height="10" class="navlink" /></a><a href="inspiration.html"><img src="../images/link_images/inspiration.jpg" alt="Inspiration" width="121" height="10" class="navlink" /></a><a href="contact.php"><img src="../images/link_images/contact.jpg" alt="Contact" width="81" height="10" class="navlink" /></a></div>
<div id="content">
<p>User Login</p>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<p>Username:
<input type="text" name="username" id="username" accesskey="u" tabindex="10" />
</p>
<p>Password:
<input type="text" name="pwd" id="pwd" accesskey="p" tabindex="20" />
</p>
<p>
<input type="submit" name="doLogin" id="doLogin" value="Log In" accesskey="l" tabindex="30" />
</p>
</form>
<p> </p>
</div>
</div>
</body>
</html>