The actual coding is rather long, but here's an idea:
Store login/password info in your MYSQL.USER table, or any table you want. You can encrypt the password with md5().
Write a query to check a match between MYSQL.USER values and values entered by user during login. Here's an sample query:
select login,md5(password) from mysql.user where login='$login' && password='$password';
If a match exists, then user is authenticated. Otherwise, do something else...
Next, put login in a session cookie. Let's say you named the cookie 'logged'.
Now, on every page on which you want authentication, use the following to check if user is logged in:
$cookielogin = $HTTP_COOKIE_VARS[logged];
if(!isset($cookielogin)
{
?>
<script>
window.location="loginPage";
</script>
<?php
}
?>
This automatically sends the user to the login page if $cookielogin was not found.
Goodluck!
Richie.
geocities.com/akindele/