 | Quote: |  | | |  | Originally Posted by pp79wc |  | | | | | | | | | Is it possible to set up HTML to require user logins to access certain features? | |  | |  | |
To do it right, you'd need a server-side scripting language like PHP or ASP. Your web host would have to support explicitly support it; most free ones don't. Who's your web host?
If your host doesn't support any server-side stuff, you could have some weak "looks like security" using only HTML and JavaScript. Here's how:
- Create a page with the HTML below. Let's say it's called "login.htm".
- In the same directory as that page, create a subdirectory to hold your private stuff. Let's say the subdirectory name is "secret".
- Have the main page in that subdirectory be named index.htm or default.htm or whatever your host sets as the default document.
- When a user accesses login.htm, they'll be prompted for a password, at which point they enter the directory name. If they enter "secret", they'll be taken to your protected directory. If not, they'll get a 404 Not Found error.
Keep in mind this method has all the security of a screen door, so don't go using it to protect your bank account number or anything. The reason it would work at all is that nobody would know to look for it. Once someone from another site links to it, it could start showing up in Google and be public to the world.
HTML Code:
<html>
<head>
<script language="JavaScript">
<!--
function askForPassword() {
location = prompt('Enter Password:', '');
}
//-->
</script>
</head>
<body onload="askForPassword();">
</body>
</html> I kept it simple for the example, but you could have a more official-looking login page that works the same way (using a textboxes instead of a prompt), so it wouldn't be quite so obvious it's only using Javascript.