jacfalcon Posted February 29, 2008 Share Posted February 29, 2008 [sOLVED]I want my website to link to a certain webpage, but I want users to have to enter a password I define, and I'll tell it to those who I want to know it.Thanks,jacfalcon Link to comment Share on other sites More sharing options...
zppblood Posted February 29, 2008 Share Posted February 29, 2008 JavaScript can be used for password protection, but is HORRIBLE for security as it's client-side meaning the user can view the source to see the password.You will want to use some kind of server-side language like PHP, ASP(.NET), Coldfusion, etc. and a database (if you want multiple accounts) for a login page. You would also be able to store it outside of the web folder so no one can access it and include it with the server-side language. Link to comment Share on other sites More sharing options...
jacfalcon Posted February 29, 2008 Author Share Posted February 29, 2008 JavaScript can be used for password protection, but is HORRIBLE for security as it's client-side meaning the user can view the source to see the password.You will want to use some kind of server-side language like PHP, ASP(.NET), Coldfusion, etc. and a database (if you want multiple accounts) for a login page. You would also be able to store it outside of the web folder so no one can access it and include it with the server-side language.If I can't find something simple, I will probably just use Javascript, since its nothing super important. All I want is a spot where people type a password and click submit. If it is the correct password, a link appears or it redirects to a link. I don't need registration or logins, just a simple kind of "if" function for the correct password or not. Link to comment Share on other sites More sharing options...
zppblood Posted February 29, 2008 Share Posted February 29, 2008 Here are a couple of ways to do it with JavaScript; one with a window prompt and another as a form with a password. <script type="text/javascript"> var password=prompt("Enter the password", ""); if (password=="MyPass") { window.location="somepage.html"; } else { alert("Incorrect"); }</script> <script type="text/javascript"> function checkPass() { var pass=document.getElementById("password").value; if(pass=="MyPass") { window.location="somepage.html"; } else { alert("Incorrect"); } }</script><form> <input type="password" id="password"> <input type="button" value="Login" onclick="checkPass()"></form> Link to comment Share on other sites More sharing options...
jacfalcon Posted February 29, 2008 Author Share Posted February 29, 2008 What parts of that code do I fill in? Just for an example, if the password was CARROT and the site I wanted users to see/redirect to was http://www.wikipedia.com what would the codes look like? Link to comment Share on other sites More sharing options...
zppblood Posted February 29, 2008 Share Posted February 29, 2008 Change MyPass to any password you want, and change somepage.html to whatever website/web page you want, but make sure it is surrounded by quotation marks. Link to comment Share on other sites More sharing options...
jacfalcon Posted February 29, 2008 Author Share Posted February 29, 2008 The second code worked like a charm (and the first one can be useful too). Thanks a lot!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.