Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Looking for simple password system or script (https://www.warriorforum.com/programming/1409394-looking-simple-password-system-script.html)

IdeasThatExcel 31st March 2020 05:45 PM

Looking for simple password system or script
 
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.

Nail Yener 17th April 2020 08:43 AM

Re: Looking for simple password system or script
 
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.


All times are GMT -6. The time now is 01:21 PM.