Click to See Complete Forum and Search --> : Hi there.


DanUK
10-26-2003, 10:21 AM
Hello there.

I was just wondering if this was achieveable with PHP itself, I have my site (at last) running 90% as I want it to.

However, I want to add a new directory called "staff" where a login box will appear (much like when you use FTP), and if that login fails, it won't let them view that directory.

At the moment, in the content files I have, I have the following PHP:


<?php
if (!eregi("page.php", $_SERVER['PHP_SELF'])) {
die ("Sorry, You cannot access this file directly...");
}

$index = 0;
include("header.php");
?>

<div align="center">
HTML content.
</div>

<?php
include("footer.php");
?>


Or is it best to just use .htaccess for this?

Many thanks if you can help.

pyro
10-26-2003, 09:43 PM
For a login, I'd recommend using sessions (http://us4.php.net/manual/en/ref.session.php). Then, on the following pages, you can just check if the session is set, and if so, you know they have logged in.