Welcome to WebmasterWorld Guest from 54.163.84.199

Forum Moderators: coopster & jatar k

displaying incorrect login data

   
4:08 pm on Apr 5, 2013 (gmt 0)



I have a login page similar to this:

<form name="form" method="post" action="xxxxxx.php">
<input name="username" type="text" id="username">
<input name="password" type="password" id="password">
<input type="submit" name="Submit" value="Login">
</form>

I'm checking the username, password against a mysql db.

If the username or password is incorrect then it displays 'wrong username or password' but it takes you to a different page.

I'm using this code for that:

session_register("username");
session_register("password");
header("location:xxxxxx.php");
}
else {
echo "Wrong Username or Password";
}

What I want to to do is have the 'wrong username or password message' to display on the same page as the login box. How do I do that? What code and where would I add?
2:58 pm on Apr 6, 2013 (gmt 0)

5+ Year Member



How about this?

<?php
$error = '';
if($incorrect_login) {
$error = 'Error message';

}
else {
$_SESSION['username'] = $USERNAME;
header("location:xxxxxx.php");
}
?>
<?php echo $error; ?>
<form name="form" method="post" action="xxxxxx.php">
<input name="username" type="text" id="username">
<input name="password" type="password" id="password">
<input type="submit" name="Submit" value="Login">
</form>

session_register is deprecated and removed as of PHP 5.4.0 [php.net...]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month