Problem with login php

What do you think is wrong with the code below?
This is supposed to check the database once the user is logged in and compare their session email with the email stored in the database and direct them to the appropriate page. Basically, if the field in Date of Birth (DOB) is null or empty, it directs them to the form and if it’s not null or not empty, it’s supposed to take them to the home page.

Unfortunately, I can’t seem to get it to work that way with this script. I’ve tried empty() and is null and even $DOB['DOB]==null but the results are never consistent – sometimes it takes them to one page and sometimes the other.

The object Getdata returns a multidimensional array with the username, password, DOB and etc. However, my query is just asking for DOB. When I do a print_r($DOB) I get an empty array with DOB=>‘the date’ and if there’s no date in the database then array is all empty =>(). What do you think the problem is? Everything seems to be correct. All the variables have the right data in them session has the email and $DOB stores the array.

require_once $_SERVER[‘DOCUMENT_ROOT’]. ‘/video_dating/includes/Database.php’;
$db = new Database();
$useremail = $_SESSION[‘email’];
$db->Query(“select DOB from users where email=‘$useremail’”);
$DOB[‘DOB’] = $db->Getdata();

if (empty($DOB))
{
include ‘profile.html.php’;
exit();
}
else
{
include ‘basic.html.php’;
exit();
}

It’s difficult to say why.

I would begin by doing a “var_dump()” of the $DOB variable to see what it is outputting to ensure you are trying the right thing.

The other option is to alter your SQL to do a check for the null:


require_once $_SERVER['DOCUMENT_ROOT']. '/video_dating/includes/Database.php';
$db = new Database();
$useremail = $_SESSION['email'];
$db->Query("select DOB from users where email='$useremail' AND DOB IS NULL");
$DOB['DOB'] = $db->Getdata();

if (count($DOB))
{
include 'profile.html.php';
exit();
}
else 
{
include 'basic.html.php';
exit();
}

Just added the " AND DOB IS NULL" to the query and altered the if statement