AshokGeetesh Posted July 9, 2014 Share Posted July 9, 2014 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 More sharing options...
davej Posted July 9, 2014 Share Posted July 9, 2014 Of course anyone can examine your Javascript file and read the password. http://www.w3schools.com/jsref/met_loc_assign.asp Link to comment Share on other sites More sharing options...
MarkT Posted July 24, 2014 Share Posted July 24, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now