Jump to content

Password Protect a Link


jacfalcon

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...