Here is the code for the page that has the error
PHP Code:
<?
//Set cookies for sessions
setcookie ("USERNAME", $_POST['username']);
setcookie ("PASSWORD", $_POST['password']);
include_once ("auth.php");
include_once ("authpaths.php");
$username = $_POST['username'];
$password = $_POST['password'];
$Auth = new auth();
$detail = $Auth->authenticate($username, $password);
if ($detail==0)
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $failure; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
else
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $success; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
?>
And this is the auth.php file that it calls:
PHP Code:
<?php
include_once ("authpaths.php");
class auth{
//DB Setings
var $HOST = "####";
var $USERNAME = "####";
var $PASSWORD = "####";
var $DBNAME = "####";
function authenticate($username, $password) {
$query = "SELECT * FROM users WHERE username='$username' AND password='$password' AND access_level <> 0";
$connection = mysql_connect($this->HOST, $this->USERNAME, $this->PASSWORD);
$SelectedDB = mysql_select_db($this->DBNAME);
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
$row = mysql_fetch_array($result);
// CHECK IF THERE ARE RESULTS
// Logic: If the number of rows of the resulting recordset is 0, that means that no
// match was found. Meaning, wrong username-password combination.
if ($numrows == 0) {
return 0;
}
else {
return $row;
}
}
}
There are some other functions in there but have not been used and are all commented out at the moment. The '####' are in place of secure information and removed for obvious reasons but are correct.
|