Page 2 of 3

Re: Password Protect Directories

Posted: Mon Apr 27, 2009 10:08 pm
by muto
Try these files:


htaccess

Code: Select all

AuthUserFile public_html/staff/.htpasswd
AuthGroupFile public_html/staff/.htgroup
AuthName Staff Intranet
AuthType Basic

<Limit GET>
require group Staff
</Limit>
htgroup

Code: Select all

Staff:test1 test2
htpasswd

Code: Select all

test1:$apr1$.axzFc1I$PRF.U46UfTWspScpKnYJM/
test2:$apr1$BpvkohtK$g0RrYZZCmZT6IL7uWhRQy/
Username:passwords are test1:test1 and test2:test2. Make sure the paths are correct in .htaccess

Also, if the server was *NIX, then the / at the start of the paths would mean it points to the wrong place..

Re: Password Protect Directories

Posted: Tue Apr 28, 2009 1:08 am
by ICT Tech
No, it didn't take that either, still got the huge error on the screen :(

Re: Password Protect Directories

Posted: Tue Apr 28, 2009 7:30 am
by muto
I can't really think of much else to try, so try sending an email to [email protected] and see if it's a server problem...

Re: Password Protect Directories

Posted: Tue Apr 28, 2009 8:26 pm
by ICT Tech
muto wrote:I can't really think of much else to try, so try sending an email to [email protected] and see if it's a server problem...
That's another problem, I don't even know who hosting24.com is, i'm not even with them :cry:
I don't know what to do know, it's just not working, I'll send an email to my host and see if they can do something their end.

Cheers :P

Re: Password Protect Directories

Posted: Tue Apr 28, 2009 9:00 pm
by muto
You can quickly create a php login page (just set a session variable, and then check for it later). Have all the pages in the staff folder do a header redirect to the login page, then exit, if they don't see the variable set.

Re: Password Protect Directories

Posted: Wed Apr 29, 2009 7:50 pm
by ICT Tech
muto wrote:You can quickly create a php login page (just set a session variable, and then check for it later). Have all the pages in the staff folder do a header redirect to the login page, then exit, if they don't see the variable set.
I hate php pages, how would you like to talk me through it, I find php really awkward.
P.S. 1 post away from being a power member muto! :P

Re: Password Protect Directories

Posted: Wed Apr 29, 2009 7:50 pm
by ICT Tech
muto wrote:You can quickly create a php login page (just set a session variable, and then check for it later). Have all the pages in the staff folder do a header redirect to the login page, then exit, if they don't see the variable set.
I hate php pages, how would you like to talk me through it, I find php really awkward.
P.S. 1 post away from being a power member muto! :P

Re: Password Protect Directories

Posted: Wed Apr 29, 2009 7:52 pm
by muto
Give me 10 minutes, and I'll post up some code you can use..

Also, double post :P

Save this as index.php in the staff folder.

Code: Select all

<?
session_start();
if (isset($_POST['username']) && isset($_POST['password']))
{
	if ($_POST['username'] == "test" && $_POST['password'] == "test")
	{
		$_SESSION['login'] = 1;
	}
	if ($_SESSION['login'])
	{
		header("Location: main.php");
		exit;
	}
}
?>
	<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="index.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Staff Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
Then, at the top of every page in the staff folder, add the following code (save as .php, not .htm).

Code: Select all

<?php
session_start();
if (!isset($_SESSION['login']))
{
	header("Location: index.php");
	exit;
}
?>

Re: Password Protect Directories

Posted: Wed Apr 29, 2009 9:55 pm
by ICT Tech
muto wrote:Give me 10 minutes, and I'll post up some code you can use..
Thanks, i'll try these in a sec!
muto wrote:Also, double post :P
Yeah, I just seen that!
Dunno what happened :lol:

Re: Password Protect Directories

Posted: Fri May 01, 2009 4:35 pm
by muto
Did the code work for you?