View Full Version : Password/Login - single input multiple output

11-27-2012, 12:18 PM

Is it possible to have like a password input field, but instead of it just checking if the password is correct or not I want it to be able to accept multiple inputs but redirect to different but specific hidden webpages.

For example if I have a client website and serviing new clients. I want there to be a single input field, but depend on the correct code that is put in it directs the user to different webpages. For example if I give John Smith access code: zx12345, and David Roberts access code: er9876 and Barry Bobs access code: byt35f.... etc etc... When they go to a login page they enter their given unique access code and it directs the user to their private page. There is only one input field for all/any login requests. Invalid codes should be given a "invalid code - please contact website admin" or redirected to a similar error page.

It could be possible that the access code is simply the webpage url, eg when John Smith enters zx12345 that the browser is redirected to http://xxxx/zx12345.html however, ideally it should be encripted such as:


Any coding whiz kids out there that can help, would be appreciated.

11-27-2012, 02:47 PM
Not purely JavaScript. You'd need a server-side language and a database, or it won't be secure.

Philip M
11-27-2012, 02:50 PM
I am sorry to say that this, although perfectly possible, is completely insecure and a waste of time. Anyone can see the passwords (whether encrypted or not) and redirect urls simply with View Source. All log-ins should be carried out using server-side scripting.

Your best plan might be to give the web pages the same names as the users or their access codes. The user John Smith would be redirected to johnsmith.html. Access code abc123 would redirect to abc123.html. That is also insecure, but rather less insecure than anything where the redirect url is visible in the code. Your access codes should be at least 10 characters in length, and completely random (knowing one code does not allow you to guess another one).

Enter Your Access Code <input type = "text" id = "acode" onblur = "redirect()">

<script type = "text/javascript">

function redirect() {
var url = document.getElementById("acode").value.toLowerCase();
url = url.replace(/[^a-z0-9]/gi,""); // only letters and numbers allowed
url += ".html";
window.location.href = url;


Also, have a look at http://www.codingforums.com/showthread.php?t=10114

Atr the end of the day security is a matter of how damaging it might be if an unauthorised user obtained access to your site. If money or its equivalent is involved you will need better security. Otherwise this ought to be sufficient.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.