-
1. Re: Authentication
John Waller Jul 20, 2011 12:51 PM (in response to erg667)Please paste the entire code here.
-
2. Re: Authentication
erg667 Jul 20, 2011 1:23 PM (in response to John Waller)<?php virtual('/deer/Connections/deer.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 = "/deer/index.html";
$MM_redirectLoginFailed = "/deer/login.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_deer, $deer);
$LoginRS__query=sprintf("SELECT userName, password FROM `admin` WHERE userName=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $deer) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//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>Untitled Document</title>
<style type="text/css">html {
height: 400px;
width: 800px;
margin-right: auto;
margin-left: auto;
background: #FFF;
}
body {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 16px;
color: #000;
background: #666;
padding: 20px;
height: 300px;
width: 750px;
margin-top: 50px;
margin-right: auto;
margin-left: auto;
border: 1px solid #333;
}
</style>
<script src="/deer/SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="/deer/SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
<link href="/deer/SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="/deer/SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
</head><body>
<h1>Please login</h1>
<form action="<?php echo $loginFormAction; ?>" method="POST" name="form1">
<p>
<span id="spryusername">
<label for="username">User Name: </label>
<input type="text" name="username" id="username" tabindex="10" />
<span class="textfieldRequiredMsg">The user name must contain 8 to 20 characters.</span><span class="textfieldMinCharsMsg">The user name must contain 8 to 20 characters.</span><span class="textfieldMaxCharsMsg">The user name must contain 8 to 20 characters.</span></span></p><p>
<span id="sprypassword">
<label for="password">Password: </label>
<input type="password" name="password" id="password" tabindex="20" />
<span class="passwordRequiredMsg">The password must contain at least 6 letters and at least 2 numbers.</span><span class="passwordMinCharsMsg">The password must contain at least 6 letters and at least 2 numbers.</span><span class="passwordMaxCharsMsg">The password must contain at least 6 letters and at least 2 numbers.</span><span class="passwordInvalidStrengthMsg">The password must contain at least 6 letters and at least 2 numbers.</span></span></p><p><input name="submit" type="submit" tabindex="30" value="Submit" /></p>
</form>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("spryusername", "none", {minChars:8, maxChars:20, validateOn:["blur"]});
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword", {validateOn:["blur"], minChars:8, maxChars:20, minAlphaChars:6, minNumbers:2});
</script>
</body>
</html>Thanks,
Robert
-
3. Re: Authentication
MurraySummers Jul 20, 2011 1:51 PM (in response to erg667)1 person found this helpful?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"Is there a space between those two things? What happens if you just delete the "?>" - surprisingly enough, it's legal.
-
4. Re: Authentication
erg667 Jul 20, 2011 2:44 PM (in response to MurraySummers)There is no space after ?>
I get a syntax error when I delete ?>
If I delete ?> but save it anyway and try to preview it in a browser I get this error
Parse error: parse error in C:\wamp\www\deer\TMP178wm21.php on line 76
Thanks for the input,
Robert
-
5. Re: Authentication
MurraySummers Jul 20, 2011 4:21 PM (in response to erg667)And what's on that line?
-
6. Re: Authentication
erg667 Jul 20, 2011 5:06 PM (in response to MurraySummers)I think I have the form working now, at least I no longer get the warning messages described earlier.
After again reviewing "Gramps" code in my other post "Authentication - Login User" I realized the very 1st line of code was wrong. When I setup the Authentication in Dreamweaver, Dreamweaver inserted this code into the beginning of the 1st line:
<?php virtual
It should read <?php require_once
Thanks "Gramps" for sending me your sample code on July 12 in my other post and thanks "Murray *ACP*" for your help today. Your suggestion about changing the last line of PHP code just before the <!DOCTYPE influenced me to review every line more closely.
Robert
-