Jump to content
Sign in to follow this  
AshokGeetesh

Creating password in HTML

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...