PDA

View Full Version : restricting access to a page



Cloughie
06-21-2007, 04:04 PM
Hi,

I was using the following code to restrict access to a page:

//start of auth check code

if( ( !isset( $_SERVER["PHP_AUTH_USER"] ) ) || ( !isset(
$_SERVER["PHP_AUTH_PW"] ) ) ||
( $_SERVER["PHP_AUTH_USER"] != "pass" ) || (
$_SERVER["PHP_AUTH_PW"] != "pass" ) )
{
header( 'WWW-Authenticate: Basic realm="Fat Loss Stack customers only - Please enter username and password emailed to you shortly after ordering the fat loss stack."' );
header( "HTTP/1.1 401 Unauthorized" );
print( "You are not authorised to view this page."
);
exit();
}
//end of auth check code

It seems to have stop working now though?

How else can I restrict access to a page? Its not massively secure information, just something simple.

webcs
07-16-2007, 09:28 AM
Why are you restricting it and how do you and it restricted?

Changing permissions or moving it to root instead of the web directory will do it.

There are a lot of kinds of restrictions so we need to know specifically what you want to accomplish.

thanks!

andyf
07-19-2007, 04:00 AM
you can restrict access for certain directory so the page ( page within that directory )via password protection using .htaccess file; this will restrict access for pages under that directory.

please ref : http://blog.webhosting.uk.com/2006/11/24/how-to-protect-a-directory-under-apache/ fo more details.

This may help you :)

Cloughie
07-19-2007, 01:44 PM
I just need a real simple access restriction, username and password.

andyf's link should do it, let me try it out later tomorrow!

Thanks for the input guys.