T
Totti
Hi everybody,
I have a Login page where the user will try to login using a user
name
and a password, found in a DB in ACCESS, the code is still very
simple, what i want to know is that how can i make a counter that
will
count till 3 wrong attempts, and close the page? I have done
something
like this in VB but there it is easier, this one here is a little bit
harder for me. At any rate, would anyone please guide me through, or
if there is such a code somewhere that i can see how it should be
approached? i am starting withe the following code:
<html> <head>
<script language=javascript>
function check()
{if (document.form1.username.value == "")
{alert("Please enter your username.");
document.form1.username.focus();}
else if (document.form1.password.value == "")
{alert("Please enter tour password.");
document.form1.password.focus();}
else {document.form1.submit();}}
</script> </head> <body>
<form name="form1" type="POST" action="http://localhost/php/estate/
after_login.php">
<div> <h1>.....Login form for Agents....</h1>
Username: <input type="text" value="" name ="username"><br><br>
Password: <input type="password" value="" name ="password"><br><br>
Number of tries: <input type="text" value="1" name ="tries" size =
"1"><br><br>
<input type="button" value="Back" onclick="history.go(-1);">
<input type="button" value="Login" onclick="check()">
</div> </form> </body> </html>
=======================================================
The page After_Login has PHP and it will check for valid login
combinations:
=======================================================
<?php
print('<html> <head></head> <body>
<form name="form1" type="post" action="http://localhost/php/estate/
props.php">
<div><h1>.....Form to Manipulate Data....</h1>');
$username = $_REQUEST["username"];
$password = $_REQUEST["password"];
$tries = $_REQUEST["tries"];
echo "\$Your username is: $username and your password is: $password
and this is your $tries attempt to login<br>";
$conn = odbc_connect ('estate','','') or die ('Error. I can not find
Estate');
$query = "select * from agent";
odbc_prepare($conn, $query) or die ('Error preparing Query');
$data = odbc_exec($conn, $query) or die ('Error executing
Query'.odbc_errormsg());
$logged = 0;
while (odbc_fetch_row($data))
{$agent_id = odbc_result($data, 'agent_id_pk');
$agent_account = odbc_result($data, 'agent_account');
$agent_password = odbc_result($data, 'agent_password');
$agent_lname = odbc_result($data, 'agent_lname');
$agent_fname = odbc_result($data, 'agent_fname');
if (($username == $agent_account) && ($password == $agent_password))
{$logged=1;}
}
if ($logged == 1)
{print('<input type="button" value="Browse Properties"
onclick="document.form1.action=\'http://localhost/php/estate/
props.php
\'; document.form1.submit();">
<input type="button" value="Browse Agents"
onclick="document.form1.action=\'http://localhost/php/estate/
agents.php
\'; document.form1.submit();">');
}
if ($logged == 0)
{print("<br>No such username or incorrect password given. Please try
again.<br>");}
print('<br><input type="button" value="Back" onclick="history.go
(-1);">
</div></form></body></html>'); ?>
=============================================================
In the best case i want the After_Login when it encounters the wrong
combination to redirect the user to the Login page, envoking a
Javascript saying how many times are yet allowed for the login, when
3
attempts are exhausted, it would be nice to close the browser
automatically and reset the counter. Is it Possible? I appreciate any
Help provided
I have a Login page where the user will try to login using a user
name
and a password, found in a DB in ACCESS, the code is still very
simple, what i want to know is that how can i make a counter that
will
count till 3 wrong attempts, and close the page? I have done
something
like this in VB but there it is easier, this one here is a little bit
harder for me. At any rate, would anyone please guide me through, or
if there is such a code somewhere that i can see how it should be
approached? i am starting withe the following code:
<html> <head>
<script language=javascript>
function check()
{if (document.form1.username.value == "")
{alert("Please enter your username.");
document.form1.username.focus();}
else if (document.form1.password.value == "")
{alert("Please enter tour password.");
document.form1.password.focus();}
else {document.form1.submit();}}
</script> </head> <body>
<form name="form1" type="POST" action="http://localhost/php/estate/
after_login.php">
<div> <h1>.....Login form for Agents....</h1>
Username: <input type="text" value="" name ="username"><br><br>
Password: <input type="password" value="" name ="password"><br><br>
Number of tries: <input type="text" value="1" name ="tries" size =
"1"><br><br>
<input type="button" value="Back" onclick="history.go(-1);">
<input type="button" value="Login" onclick="check()">
</div> </form> </body> </html>
=======================================================
The page After_Login has PHP and it will check for valid login
combinations:
=======================================================
<?php
print('<html> <head></head> <body>
<form name="form1" type="post" action="http://localhost/php/estate/
props.php">
<div><h1>.....Form to Manipulate Data....</h1>');
$username = $_REQUEST["username"];
$password = $_REQUEST["password"];
$tries = $_REQUEST["tries"];
echo "\$Your username is: $username and your password is: $password
and this is your $tries attempt to login<br>";
$conn = odbc_connect ('estate','','') or die ('Error. I can not find
Estate');
$query = "select * from agent";
odbc_prepare($conn, $query) or die ('Error preparing Query');
$data = odbc_exec($conn, $query) or die ('Error executing
Query'.odbc_errormsg());
$logged = 0;
while (odbc_fetch_row($data))
{$agent_id = odbc_result($data, 'agent_id_pk');
$agent_account = odbc_result($data, 'agent_account');
$agent_password = odbc_result($data, 'agent_password');
$agent_lname = odbc_result($data, 'agent_lname');
$agent_fname = odbc_result($data, 'agent_fname');
if (($username == $agent_account) && ($password == $agent_password))
{$logged=1;}
}
if ($logged == 1)
{print('<input type="button" value="Browse Properties"
onclick="document.form1.action=\'http://localhost/php/estate/
props.php
\'; document.form1.submit();">
<input type="button" value="Browse Agents"
onclick="document.form1.action=\'http://localhost/php/estate/
agents.php
\'; document.form1.submit();">');
}
if ($logged == 0)
{print("<br>No such username or incorrect password given. Please try
again.<br>");}
print('<br><input type="button" value="Back" onclick="history.go
(-1);">
</div></form></body></html>'); ?>
=============================================================
In the best case i want the After_Login when it encounters the wrong
combination to redirect the user to the Login page, envoking a
Javascript saying how many times are yet allowed for the login, when
3
attempts are exhausted, it would be nice to close the browser
automatically and reset the counter. Is it Possible? I appreciate any
Help provided