Jason,
I am still having problems with this, I have redone everything over, as per the tutorial, I am not getting any error notices but, now I am not able to login, getting login failed, it worked fine before adding this remember me code, so I must have messed something up. I am including my code, is this the right way to include code ? Thx for your help
<?php require_once('Connections/fradmin.php'); ?>
<?php
if (isset($_POST['pwd'])) { $_POST['pwd'] = sha1($_POST['pwd']); }
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['pwd'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "loginfail.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_fradmin, $fradmin);
$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, $fradmin) 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 );
}
}
?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("remember", "".((isset($_POST["username"]))?$_POST["username"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("password", "".((isset($_POST["pwd"]))?$_POST["pwd"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("remember", "1", time()+(60*60*24*30), "/", "", 0);
}
?>
<!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=iso-8859-1" />
<title>Nascar Sprint Cup Fantasy Racing League Login</title>
<!--[if lte IE 7]>
<link href="styles/p7_42street_msie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link href="styles/2009.css" rel="stylesheet" type="text/css" media="screen" />
<link href="styles/2009print.css" rel="stylesheet" type="text/css" media="print" />
</head>
<body onload="P7_rowLite('liteTb1','rowLite')">
<div id="masthead">
<div id="logodiv">
<img src="images/logo2008.gif" alt="Nascar Sprint Cup Fantasy Racing League" width="770" height="111"/>
</div>
</div>
<div id="wrap_outer">
<div id="wrap_inner">
<div id="nav_wrapper">
<img src="images/logo_sprintcup.jpg" alt="Nascar Sprint Cup Racing" width="90" height="47" />
</div>
<div id="mainbox">
<div id="maincontent">
<h3>Member Login </h3>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<p>
<label for="username">Username:</label>
<input name="username" type="text" id="username" value="<?php echo((isset($_COOKIE["username"]))?$_COOKIE["username"]:"") ?>" size="15" />
</p>
<p>
<label for="pwd">Password:</label>
<input name="pwd" type="password" id="pwd" value="<?php echo((isset($_COOKIE["password"]))?$_COOKIE["password"]:"") ?>" size="15" />
</p>
<p>
<label for="rememberme">Remember me</label>
<input <?php if (!(strcmp(((isset($_COOKIE["remember"]))?$_COOKIE["remember"]:""),1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="rememberme" id="rememberme" />
</p>
<p>
<input type="submit" name="doLogin" id="doLogin" value="Login" />
</p>
</form>