hey, i'm trying to write a function that checks a username and password (on submission) against a database and then sets a global session variable as a user type for authentication on other pages. my function is as follows:
i've got a few things in there because i'm trying to get it to work at the moment. buildArray() queries the database and returns the array $this->blog...which looks something like this:
however, my session variables aren't setting, and it's really starting to confuse me. upon echoing the $_SESSION[usertype], it's not doing anything. i'm thinking this is because i've set the variable incorrectly, but i can't see how. can someone please help me?
Code:
function userCheck()
{
$this->buildArray("SELECT * FROM member WHERE username='$_REQUEST[username]' AND password='$_REQUEST[password]'");
if ($this->arrayCount !== 1)
{
header("Location: error.php");
}
else
{
print_r($this->blog);
$_SESSION['usertype'] = $this->blog['user_type'];
$_SESSION['username'] = $this->blog['username'];
echo "$_SESSION[usertype]";
}
}
i've got a few things in there because i'm trying to get it to work at the moment. buildArray() queries the database and returns the array $this->blog...which looks something like this:
Code:
Array ( [0] => Array ( [0] => 1 [id] => 1 [1] => Jasper [username] => Jasper [2] => DELETED** [password] => DELETED** [3] => admin [user_type] => admin ) )
however, my session variables aren't setting, and it's really starting to confuse me. upon echoing the $_SESSION[usertype], it's not doing anything. i'm thinking this is because i've set the variable incorrectly, but i can't see how. can someone please help me?