Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

php/js help


ghost's Avatar
0 0

i´ve get interested in real11, where you have only one chance to login, if you fail, the login form will get disabled.. how can i do this in my login script? thanks


ghost's Avatar
0 0

well, I'm no expert at php, but I'm guessing you could do something like:

if (login==failed){echo "login disabled"} else {echo "form"};

ghost's Avatar
0 0

yes that is probably it, thanks


ghost's Avatar
0 0

<input type="submit" disabled="disabled"> :)


ghost's Avatar
0 0

mr noob wrote: <input type="submit" disabled="disabled">

you would be able to bypass that quite easily though, probably :|


ghost's Avatar
0 0

smufkin wrote:

you would be able to bypass that quite easily though, probably :|

yeah i think the web developer toolbar would get passed that nicely

go with smufkins php code as that would work i think


mido's Avatar
Member
0 0

Web developer, DOM inspector, Firebug, any debugger. Btw, you can also do something like this :

document.forms[0].address.disabled = true

This to disable the form element with name="address".


ghost's Avatar
0 0

yes, but i must declare the variable login first, and when user will refresh the page, it will be automatically setted back to true


mido's Avatar
Member
0 0

And you can set a session if the form elements weren't entered correctly

I've written a quick script for you, it uses sessions.

<?php session_start(); $username=$_POST['username']; $password=$_POST['password']; if (session_is_registered("locked")) { echo "<head> <script> function disbl() { document.forms[0].button1.disabled=true document.forms[0].username.disabled=true document.forms[0].password.disabled=true } </script> </head> <body onLoad='disbl()'> <form method='POST' action=''> <input type='text' name='username'> <br /> <input type='password' name='password'> <br /> <input type='submit' name='button1'> </form> "; exit; }

if (isset($username) && isset($password)) { if ($username == "admin" && $password == "adminpassword") { echo "Logged In"; }

else if ($username != &quot;admin&quot; && $password != &quot;adminpassword&quot;)
{
session_register(&quot;locked&quot;);
echo &quot;&lt;head&gt;
&lt;script&gt;
function disbl()
{
document.forms[0].button1.disabled=true
document.forms[0].username.disabled=true
document.forms[0].password.disabled=true
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onLoad=&#39;disbl()&#39;&gt;
&lt;form method=&#39;POST&#39; action=&#39;&#39;&gt;
&lt;input type=&#39;text&#39; name=&#39;username&#39;&gt;
&lt;br /&gt;
&lt;input type=&#39;password&#39; name=&#39;password&#39;&gt;
&lt;br /&gt;
&lt;input type=&#39;submit&#39; name=&#39;button1&#39;&gt;


&lt;/form&gt;
&quot;;
exit;
}

} elseif (!isset($username) || !isset($password)) {

echo " <body> <form method='POST' action=''> <input type='text' name='username'> <br /> <input type='password' name='password'> <br /> <input type='submit' name='button1'> </form> "; exit; }

?>

EDIT : Use $_SESSION better. Damn smiles!


ghost's Avatar
0 0

ok, very thanks, mido, i will use it with my login form… but i have last question for this thread, i want to add under main login form little square, that indicates if the login system is active or not.. this is no problem, when the user come on the page, it indicates login system status : active, but when the user enter incorrect data, it will get locked (solved) and login system status : active will be switched to login system status : disabled, but when it indicates disabled, i want to add a link under it, that will enable the login system… it will open small window, which will request the random pass based on any system, and then unlock the form if the pass is correct… i need help with this two last things.. anyway, thank you mido for your help


ghost's Avatar
0 0

so finally i have it… i have two versions of form, when users fails with loggining in, his ip will be written into mysql… on the load of page will be checked the list of banned ips in database, if you dont have banned ip, you see unlocekd form, if have, you see the locked form… of course you still have chance to unlock the form, if you are member you can enter your username, password and the ip and you´ve get unlocked ;)


mido's Avatar
Member
0 0

That would be more nicer, since sessions can be deleted very easily.