[QUOTE=IBazz;4774727]I would try it like this.
create table users
( id int not null auto_increment primary key
, first_name varchar(99)
, last_name varchar(99)
, user_name varchar(99)
, DOB DATE
, password varchar(99)
) engine=innodb
create table user_attributes
( id int not null auto_increment primary key
, user_id int not null
, attribute_type varchar(99)
, attribute varchar(99)
) engine=innodb
the user_attributes table would contain data like this
| id | user_id | attribute_type | attribute |
| 1 | 1 | eye colour | blue |
| 2 | 1 | hair colour | brown |
| 3 | 1 | beard colour | NULL |
Question. 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 page 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 here’ 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(); //returns md array
if (empty($DOB))
{
include ‘profile.html.php’;
exit();
}
else
{
include ‘basic.html.php’;
exit();
}