HTML private areas

liunx

Guest
right ive just made a new web page - for a clan on counter strike.<br />
<br />
ive got a little private area that is for members only.<br />
<br />
how do i make this a passworded area to access the page ?<br />
<br />
thanks Shaft<!--content-->well you have a couple of choices. if you are on your site and you pay monthly for the host privledges then you can use .htaccess and .htpasswd file to set the login procedure. tutorials for those can be found here (<!-- m --><a class="postlink" href="http://www.snippetlibrary.com/tutorials.php?kid=20&catname=Apache">http://www.snippetlibrary.com/tutorials ... ame=Apache</a><!-- m -->) <br />
<br />
or you can use serverside language like php, asp, cgi to do that. but then again you have to be on a server that allows serverside language to be run. if you are on a free server then chances are you won't be able to.<!--content-->1. You will need a "Default page" linked from your site.<br />
<HTML><br />
<HEAD><br />
<TITLE>Password Tester</TITLE><br />
</HEAD><br />
<br />
<SCRIPT LANGUAGE="JavaScript"><br />
<!--<br />
function GetPassword() {<br />
window.open("jspass.htm", "","width=225,height=50")<br />
}<br />
//--><br />
</SCRIPT><br />
<br />
<BODY><br />
<br />
<A HREF=http://www.htmlforums.com/archive/index.php/"javascript:GetPassword()">Password page</A> (requires a password)<br />
<br />
</BODY><br />
</HTML><br />
<br />
2. Then a page that asks for a password:<br />
<HTML><br />
<HEAD><br />
<TITLE>Password Required</TITLE><br />
</HEAD><br />
<br />
<SCRIPT LANGUAGE="JavaScript"><br />
<!--<br />
<br />
function SubmitPassword(frm)<br />
{<br />
//<br />
// Get the value entered into the text box<br />
//<br />
var password = frm.pw.value<br />
//<br />
// Convert it to lowercase<br />
//<br />
password = password.toLowerCase()<br />
//<br />
// Add the .htm extension<br />
//<br />
var loc = password + ".htm"<br />
//<br />
// Make sure the user entered something<br />
//<br />
if (password != "")<br />
{<br />
//<br />
// If so, send the browser there<br />
//<br />
opener.location.href = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/loc">http://www.htmlforums.com/archive/index.php/loc</a><!-- m --><br />
}<br />
//<br />
// Close this window<br />
//<br />
window.close()<br />
}<br />
<br />
//--><br />
</SCRIPT><br />
<br />
<BODY BGCOLOR="#CCCCCC"><br />
<br />
<FORM><br />
This page requires a password:<BR><br />
<INPUT TYPE="TEXT" NAME="pw" SIZE=15><br />
<INPUT TYPE="BUTTON" VALUE="OK"<br />
onClick="SubmitPassword(this.form)"><br />
</FORM><br />
<br />
</BODY><br />
</HTML><br />
<br />
3. Then a password - protected page:<br />
<HTML><br />
<HEAD><br />
<TITLE>You Made It!</TITLE><br />
</HEAD><br />
<br />
<BODY><br />
<br />
Welcome to the password-protected part of the site! <br />
<br />
</BODY><br />
</HTML><!--content--><script><br />
<br />
function submitentry(){<br />
password = document.password1.password2.value.toLowerCase()<br />
username = document.password1.username2.value.toLowerCase()<br />
passcode = 1<br />
usercode = 1<br />
for(i = 0; i < password.length; i++) {<br />
passcode *= password.charCodeAt(i);<br />
}<br />
for(x = 0; x < username.length; x++) {<br />
usercode *= username.charCodeAt(x);<br />
}<br />
<br />
if(usercode==134603040&&passcode==126906300)<br />
<br />
{<br />
window.location=password+".htm"}<br />
else{<br />
alert("password/username combination wrong")}<br />
}<br />
</script><br />
<br />
<form name="password1"><br />
<strong>Enter username: </strong><br />
<input type="text" name="username2" size="15"><br />
<br><br />
<strong>Enter password: </strong><br />
<input type="password" name="password2" size="15"><br />
<br />
<input type="button" value="Submit" onClick="submitentry()"><br />
</form><br />
<br />
rite this is the code i have tryed<br />
<br />
now this doesnt work ?<br />
<br />
y not ?<!--content-->Then read--<<--This-->> (<!-- m --><a class="postlink" href="http://www.htmlgoodies.com/tutors/pw.html">http://www.htmlgoodies.com/tutors/pw.html</a><!-- m -->) <br />
<br />
Then ask your self what can be so important to go to all the trouble. :D<br />
<br />
The script I gave is just the script you will need to include in the pages after everything else has been set up.<!--content-->Short of using the .htaccess/.htpasswd files or server side language to provide access to password protected areas of a site you can not provide enough security. <br />
<br />
client side methods can be easily hacked by any visitors with a minium of javascript knowledge.<!--content-->
 
Back
Top