Forums
This topic is locked
Keep login form value a validation failed
Posted 02 Sep 2007 22:03:14
1
has voted
02 Sep 2007 22:03:14 Roseline Paquin posted:
Hi,i made a login page which is redirecting to hitself if validation fail or another page if it's a success.
Is it possible to keep the value of the username and password even if it's wrong?
I tried to assign the values in the form of my input: <?php echo $_POST['username']; ?><?php echo $_POST['password']; ?>
Here is my code. Thanks for your help,
ROseline
<?php
// *** Validate request to login to this site.
session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($_POST['login'])) {
$loginUsername=$_POST['login'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "sucess.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_menfusion, $menfusion);
$LoginRS__query=sprintf("SELECT nom, pass FROM clients2 WHERE nom='%s' AND pass='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $menfusion) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
session_register("MM_Username"
session_register("MM_UserGroup"
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>