Mcjohnes Posted September 18, 2014 Share Posted September 18, 2014 hello i need help with a simple javascript simple login form, i am building a small website for I and my classmates. i want it to be able to redirect each user to a specific page when a corresponding passcode is entered, i know its unsafe but we dont plan on keeping valuable information on the site, i dont know about MSQL and dont even wish to use it, the code works at this level but am unable to add users since i dont understand javascript if someone could help me i will be very grateful thanks in advance /*here is the code i got so far*/<tittle>Enter Passcode to proceed</title><h1 style="font-family:Comic Sans Ms;text-align="center";font-size:20pt;color:#00FF00;></h1><form name="login">Passcode: <input type="text" name="userid"/><input type="button" onclick="check(this.form)" value="Login"/><input type="reset" value="Cancel"/></form><script type="text/javascript">function check(form)/*function to check userid */{ /*the following code checkes whether the entered userid is correct*/ if(form.userid.value == "JohnDoe") { window.open("johndoe.php")/*opens the target page while Id */ } else { alert("Invalid Passcode, please try again!")/*displays error message*/ }}</script> Link to comment Share on other sites More sharing options...
Ingolme Posted September 18, 2014 Share Posted September 18, 2014 It's not just "unsafe", it provides absolutely zero security, honestly. For what it's worth you might as well have a list of links to each corresponding page and ask them politely not to visit pages that don't correspond to them. 1 Link to comment Share on other sites More sharing options...
davej Posted September 18, 2014 Share Posted September 18, 2014 Don't try to use Javascript for this. Use Php. http://www.w3schools.com/php/ Link to comment Share on other sites More sharing options...
johncc Posted September 18, 2014 Share Posted September 18, 2014 (edited) I agree that a server side script is the way to go. I have used this simple Perl one to "to redirect each user to a specific page". http://www.rlaj.com/cgi-bin/download/freedownload.cgi?RegDownload&passredir&Passwd+Redirect Edited September 18, 2014 by johncc 1 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