How and where to add code to login page
I have a login page which uses the Dreamweaver Login Behavior. I want to add code to:
Check the status of the person loging in (status is the last field in the mySQL authentication table).
a. If the person is already logged in, display an error message, and reject the attempt.
b. If the person is NOT currently logged in, set his status accordingly, and log him in.
Since the behavior is generated code, and well above my head, I don't know what code to enter, and where to enter it. Here's the code for the form:
<?php require_once('Connections/login.php'); ?>
<?php
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 = "";
$MM_redirectLoginSuccess = "WOTCPg1.php";
$MM_redirectLoginFailed = "loginerror.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_login, $login);
$LoginRS__query=sprintf("SELECT UserID, Password FROM authentication WHERE UserID=%s AND Password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $login) 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><script type="text/javascript">
function setFocus()
{
document.getElementById("username").focus();
}
</script><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Log-in to IOD</title>
<style type="text/css">
<!--
#apDiv3 {
position:absolute;
left:5px;
top:101px;
width:760px;
height:612px;
z-index:2;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
color: #009;
text-align: center;
background-image: url(images/grid_gray.gif);
border: medium ridge #009;
}
#apDiv1 {
position:absolute;
left:94px;
top:227px;
width:629px;
height:282px;
z-index:3;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: none;
color: #009;
text-align: center;
}
#apDiv2 {
position:absolute;
left:178px;
top:248px;
width:564px;
height:254px;
z-index:3;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: none;
color: #009;
text-align: left;
border: medium groove #036;
}
#apDiv4 {
position:absolute;
left:178px;
top:245px;
width:566px;
height:242px;
z-index:3;
border: medium groove #009;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: capitalize;
color: #009;
}
.SubmitButton {
color: #009;
}
-->
</style>
</head><body onLoad="setFocus()" >
<span style="position:absolute; left:3px; top:2px; width:758; height:89;"><img src="sitebuilder/preview/sitebuilder/clipart/bars/regular/horizontal/sleekLines_blue.gif" width="760" height="90" alt="" /></span>
<div id="e2" style="position:absolute; left:13px; top:14px; width:670px; height:32;"><span class="text"><b><span style="font-size: 22px"><font color="#FFFFFF">Sign-in to Information On Demand</font></span><font color="#FFFFFF" size="4"><span style="font-size:22px;line-height:26px;"><br soft="soft" />
</span></font></b></span></div>
<div id="apDiv3">
<p><span style="text-align: center; text-decoration: underline; color: #009; text-transform: capitalize; font-variant: normal; font-weight: bold; line-height: normal; font-style: normal; font-size: 18pt; font-family: Arial, Helvetica, sans-serif;">Customer Sign-In</span><span style="position:absolute; left:12px; top:23px; width:151px; height:65;"><img src="sitebuilder/images/redInfoOnDemandLogo-150x65.jpg" width="149" height="65" alt="" /></span></p>
</div>
<div id="apDiv4">
<form ACTION="<?php echo $loginFormAction; ?>" id="login" name="login" method="POST">
<p> </p>
<p>User Name:<br /><input name="username" type="text" id="username" tabindex="1" size="30" maxlength="30" />
</p>
<p>User's Password:<br />
<input type="password" name="password" id="password" tabindex="2" />
</p>
<p>
<input name="submit" type="submit" class="SubmitButton" id="submit" tabindex="3" style="color:#009; font-weight:bold" value="Sign-in" />
<input type="reset" name="reset" id="reset" value="Reset" tabindex="4" style="color:#009; font-weight:bold"></p>
</form>
</div>
<br />
</div>
</body>
</html>
Here's the code for the script "included" in the first line of the page:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_login = "localhost"; // Change to "mysql" when uploaded to Yahoo
$database_login = "infoondemand";
$username_login = "root"; // Change to "creacontech" when uploaded to Yahoo
$password_login = "raisin4312";
$login = mysql_pconnect($hostname_login, $username_login, $password_login) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Could someone help me with this? I'd very much appreciate any assistance.
