Jump to content

Creating password in HTML


AshokGeetesh

Recommended Posts

Hi,

 

Please could you help me on the below codings.

 

I have set the password in below codings, but i want to know few things. ie if we provide correct password it should move to hyperlink. ex: WWW.GOOGLE.COM instead of giving me as "Correct",

 

<head><script type="text/javascript">function isValid(){var password = document.getElementById('password').value;if (password == "G0ld"){alert('Correct!')}else{alert('Wrong Password')}}</script></head>

<form name="PasswordField" action="">Password:<input type="password" id="password" name="password"><input type="button" value="Log in" onclick="isValid();"></form>

 

 

Thanks,

AshokGeetesh

Link to comment
Share on other sites

  • 2 weeks later...

It is not recommended to use javascript for passwords, it is extremely vulnerable thanks to the help of inspect element and view source.

 

I would recommend using a PHP if statement alongside a HTML form.

 

With the PHP, you can use a simple meta refresh tag to load up google if the password matches the one that you want to.

 

For example;

<?PHPif($_POST['password'] == "G0ld") {echo '<meta http-equiv="refresh" content="2;url=http://www.google.com" /> Password Correct '; }else {die("Sorry, password incorrect"); ?>

Hope this helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...