My auth.php is simply connecting to the database like this:
class auth{
// CHANGE THESE VALUES TO REFLECT YOUR SERVER'S SETTINGS
var $HOST = "localhost"; // Change this to the proper DB HOST
var $USERNAME = "db_username"; // Change this to the proper DB USERNAME
var $PASSWORD = "db password"; // Change this to the proper DB USER PASSWORD
var $DBNAME = "db_name"; // Change this to the proper DB NAME
And the code I am using at the top of the pages I want to be accessed by members only is:
<?php
include_once ("members/auth.php");
include_once ("members/authconfig.php");
include_once ("members/check.php");
?>
My login.php is posting to:
action="<? print &resultpage ?>">
and the check.php page is pasted below:
if (isset($_COOKIE['USERNAME']) && isset($_COOKIE['PASSWORD']))
{
// Get values from superglobal variables
$USERNAME = $_COOKIE['USERNAME'];
$PASSWORD = $_COOKIE['PASSWORD'];
$CheckSecurity = new auth();
$check = $CheckSecurity->page_check($USERNAME, $PASSWORD);
}
else
{
$check = false;
}
if ($check == false)
{
// Feel free to change the error message below. Just make sure you put a "\" before
// any double quote.
print "<font face=\"Arial, Helvetica, sans-serif\" size=\"5\" color=\"#FF0000\">";
print "<b>Illegal Access</b>";
print "</font><br>";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#000000\">";
print "<b>You do not have permission to view this page.</b></font>";
// REDIRECT BACK TO LOGIN PAGE
// REMOVE BLOCK IF NOT BEING USED
print "<br>";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">";
print "You will be redirected back to the login page in a short while.</font>";
?>
<HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $login; ?>");
//-->
</SCRIPT>
</HEAD>
<?
// END OF REDIRECTION BLOCK
exit; // End program execution. This will disable continuation of processing the rest of the page.
}
?>