homepage Welcome to WebmasterWorld Guest from 54.197.65.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
displaying incorrect login data
jp12



 
Msg#: 4561738 posted 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?

 

jojy

5+ Year Member



 
Msg#: 4561738 posted 2:58 pm on Apr 6, 2013 (gmt 0)

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...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved