this is the most strange problem i have come accross, i cant see any problems with my code and i have tried everything i can think of to try and fix it but yet the problem still persists
here is my sentry.php file
Code:
<?php
class Sentry
{
var $loggedin = false;
var $userdata;
function sentry()
{
session_start();
header("Cache-control: private");
}
function logout()
{
unset($this->userdata);
session_destroy();
return true;
}
function checkLogin($user = '',$pass = '',$group = 10,$goodRedirect = '',$badRedirect = '')
{
require_once('DBConnector.php');
require_once('Validator.php');
$validate = new Validator();
$connector = new DBConnector();
if($_SESSION['user'] && $_SESSION['pass'])
{
if(!$validate->validateTextOnly($_SESSION['user']))
{
return false;
}
if(!$validate->validateTextOnly($_SESSION['pass']))
{
return false;
}
$getUser = $connector->Query("SELECT * FROM members WHERE Username='" . $_SESSION['user'] . "' AND Password='" . $_SESSION['pass'] . "' AND Group<='" . $group . "' AND Status=1");
if($connector->GetNumRows($getUser) > 0)
{
if($goodRedirect != '')
{
header("Location: ".$goodRedirect."?".strip_tags(session_id())) ;
}
return true;
}else{
$this->logout();
return false;
}
}else{
if(!$validate->validateTextOnly($user))
{
return false;
}
if(!$validate->validateTextOnly($pass))
{
return false;
}
$getUser = $connector->Query('SELECT * FROM members WHERE Username="$user" AND Password=MD5("$pass") AND Group<="$group" AND Status="1"');
$this->userdata = $connector->GetArray($getUser);
if($connector->GetNumRows($getUser) > 0)
{
$_SESSION["user"] = $user;
$_SESSION["pass"] = $this->userdata['Password'];
$_SESSION["group"] = $this->userdata['Group'];
if ($goodRedirect)
{
header("Location: ".$goodRedirect."?".strip_tags(session_id()));
}
return true;
}else{
unset($this->userdata);
if ($badRedirect)
{
header("Location: ".$badRedirect);
}
return false;
}
}
}
}
?>
the problem is with the query line that is supposed to return the resource id
Code:
$getUser = $connector->Query('SELECT * FROM members WHERE Username="$user" AND Password=MD5("$pass") AND Group<="$group" AND Status="1"');
it doesnt store or return any value, e.g. if i echo it normally it would say something like Resource #id3, but nothing if i echo it it returns nothing at all, my query is correct i am sure as i have tested it in phpmyadmin by means of sql querying and it returs values then.
here are some additional errors that dont make sense other than the fact it is because the query returns nothing that are displayed at the top of the login.php page when you try to login
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in H:\xampp\htdocs\phpcms\includes\DBConnector.php on line 41
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in H:\xampp\htdocs\phpcms\includes\DBConnector.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at H:\xampp\htdocs\phpcms\includes\DBConnector.php:41) in H:\xampp\htdocs\phpcms\includes\Sentry.php on line 79
hope someone can spot anything i have missed coz im stumped on this one
cheers
craig