Login Script Help
Posted: Sun Jan 22, 2006 1:26 pm
hey!
i have a password script that works right now
we will name this login script #1
basically it starts out with just the password form, and if its incorrect it will display password is incorrect..
i would like to upgrade my login form, right now my code is
we will name this login script #2
is there any way to make login script #2 like login script#1 where it doesnt display user name or password is incorrect before something is submitted, get what i mean?
so what i want to basically do
1. Make a login script with 2 users.
2. If the password or username is wrong, it will display "password or username is wrong.."
3. I dont want it to view "password or username is wrong..." when the form has not been submitted yet
4. I want it to process on the same page.
thank you!!!
special thanks to jshpro2, for helping me with the new login script
i have a password script that works right now
Code: Select all
<?
function showForm() {
echo "<form method=post action=/pages/login.php><br>admin id# :<br> <input type=password name=pw><br />
<input type=submit>
</form>";
}
$content = "welcome";
$wrong = "<html><font size=-1 color=red><b>THE PASSWORD YOU ENTERED IS INCORRECT</b></font></html>";
//check if something was entered into field
if(!empty($HTTP_POST_VARS['pw'])) {
if($HTTP_POST_VARS['pw'] == 'mypassword') {
echo $content;
}
else {
showForm();
echo $wrong;
}
}
else {
showForm();
}
?>basically it starts out with just the password form, and if its incorrect it will display password is incorrect..
i would like to upgrade my login form, right now my code is
Code: Select all
<?
if ($_POST['user']=='bob' && $_POST['pass']=='bobs') {header('Location:http://www.google.com');
}
elseif($_POST['user']=='john' && $_POST['pass']=='johns') {header('Location:http://www.google.com');
}
else {echo "wrong user name or password";}
?>
<html>
<div align=center><form action="test.php" method="post"><font size=2><b>Username:
<input type=text size=5 maxlength=5 name=user><br>
<font size=2><b>Password:
<input type=password size=5 maxlength=5 name=pass><br><input type=submit value=Login.>
</form>
</div>is there any way to make login script #2 like login script#1 where it doesnt display user name or password is incorrect before something is submitted, get what i mean?
so what i want to basically do
1. Make a login script with 2 users.
2. If the password or username is wrong, it will display "password or username is wrong.."
3. I dont want it to view "password or username is wrong..." when the form has not been submitted yet
4. I want it to process on the same page.
thank you!!!
special thanks to jshpro2, for helping me with the new login script