View Full Version : Site passwords...help please!
Does anyone know how I can add password facility to specific pages in a site?
Your help would be very appreciated :)
Ta in advance
I certainly do http://forums.gameplay.com/ubb/teeth.gif
There are two main ways.
1. Server Side. This is very secure but requires CGI support on your server and messing with nasty files called .htaccess. Its worth it if your host supports it because it is by far the most secure way of doing it.
2. Java script. Its not hugely secure but it will keep out most people. And here's how:
Put this between the <HEAD></HEAD> tags:
<BLOCKQUOTE><font size="1" face="Verdana">code:</font><HR><pre>
<script language="JavaScript">
function checkit() {
mook = jinxed.funky.value + '.html'
location.href = mook
}
</script>
[/code]
And then put this somewhere on your page:
<BLOCKQUOTE><font size="1" face="Verdana">code:</font><HR><pre>
<FORM name="jinxed">
Enter Password: <input type="Password" name="funky" size="10" maxlength="10">
<INPUT TYPE="BUTTON" VALUE="Enter" onclick="checkit()">
</FORM>
[/code]
Basically, your password will be the name of the page you want to load without the .html bit. So if you want to protect a page called secret.html, link to a page with the above code in it and then your password will be secret. The javascript will add .html to it and load it as a page. If you type in the wrong password you get an Error 404 - page not found. This is a good way to do it as the password is not within the source code of the page. Just be sure to have an index.html page in the same directory as your protected page to prevent people browsing to it directly.
[This message has been edited by Jinx M (edited 27-06-2000).]
Jinx, you are a diamond mate http://forums.gameplay.com/ubb/teeth.gif thanks
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.