i'm having some trouble with my remember me! script... i am new to php so i'm sure i have something in the wrong order or out of place, etc.... does anyone have suggestions? right now, the cookies get set if the remember checkbox is checked when a user logs in, but then nothing is displayed in the username and password field when they logout and go back to the index.php... i want it so that when a user chooses remember checkbox, the checkbox will always be checked, the username field will always have their username, and the password field will have their password as bullets (the amount of characters before sha1.
Code: Select all
if (array_key_exists('doLogin', $_POST)) {
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "USERprofile.php";
$MM_redirectLoginFailed = "indexfailed.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connUser, $connUser);
if ($_POST['remember']) {
setcookie("cookname", "mysite", time() + 9999999);
setcookie("cookpassword", "mysite", time() + 9999999);
}
Code: Select all
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<p>
<label for="username">Username</label>
<?php if ($_COOKIE['cookname']) { echo $loginUsername; } ?>
<input name="username" type="text" id="username" size="22" />
<label for="password">Password</label>
<?php if ($_COOKIE['cookpassword']) { echo $password; } ?>
<input name="password" type="password" id="password" size="22" />
</p>
<a href="USERforgotUserPassword.php">Forgot password and/or username?</a>
<p>
<label for="doLogin"></label>
<input type="submit" name="doLogin" id="doLogin" value="Login" />
<input type="checkbox" name="remember" id="remember" />
<?php if (($_COOKIE['cookname']) && $_COOKIE['cookpassword')) { echo 'checked'; } ?>
Remember Me!</p>
</form>