Looking for simple password system or script

1 replies
Can anyone point me to a simple password script or website that shows how to do something like this...

The user is asked to enter a passcode.

Let's say want to have 3 passwords.....

If a user enters ABC they go to www.aa.com
If a user enters DDD they go to www.dd.com
If a user enters ZYZ they go to www.zz.com
if no match they get an error message


Thanks in advance.
#password #script #simple #system
Avatar of Unregistered
  • Profile picture of the author Nail Yener
    It looks like this is not a username-password thing. You can accomplish a code-based redirection like this by adding some JavaScript to your page:

    HTML Code:
    <input type="text" id="code" placeholder="Enter Your Code">
    <button type="button" id="enter">Enter</button>
    <div id="notice"></div>
    
    <script>
    var codes = {
    	'code1' : 'http://www.google.com/',
    	'code2' : 'http://www.youtube.com/',
    	'code3' : 'http://www.twitter.com/',
    };
    
    document.getElementById('code').oninput = function() {
    	document.getElementById('notice').innerHTML = ''
    }
    
    document.getElementById('enter').onclick = function() {
    	var code = document.getElementById('code').value;
    	if (code != '' && code in codes) {
    		window.location.href = codes[code];
    	} else {
    		document.getElementById('notice').innerHTML = '!! Invalid code entered.'
    	}
    };
    </script>
    You can add more codes, edit redirect URLs, error message, style the input box and button etc. as you wish.
    {{ DiscussionBoard.errors[11591873].message }}

Trending Topics