如何检测用户是否接受了条款?

Basically I am writing a PHP and MYSQL script that will check whether a user has accepted the terms and conditions or not. In the databse every current user that has signed up is set to "unaccepted". When they log in the first page that they are directed to should have a scirpt on it that detects whether or not the status of the tos column in the users table is set to "accepted" or "unaccepted". If it is accepted they can continue, and if it is not they they will be forced to go to a page and accept them before they can continue to use the rest of my site. This is the code so far but it doesn't seem to be working. Any suggestions help.

<?php

$username=$_SESSION['username'];
$connect = mysql_connect('**', '**', '**', '**');
if (!$connect) 
{
    die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db('**')) 
{
    die('Could not select database: ' . mysql_error());
}
$toschecker = mysql_query("SELECT `tos` FROM `users` WHERE `username` = '$username'");
if (!$toschecker) 
{
    die('Could not query:' . mysql_error());
}
mysql_close($connect);
$unaccepted='unaccepted';

if ($toschecker === $unaccepted)
{
    header('Location: accepttos.php');
}    
?>

For some reason this isn't directing them to the accepttos.php page. Thanks in advance.

Change MySQL to MySQLi. Explanations are in the comments.

<?php

$username = $_SESSION['username'];
$connect = mysqli_connect('Host', 'Username', 'Password', 'Database');
if (!$connect) 
{
    die('Could not connect: ' . mysql_error());
}

$toschecker = mysqli_query($connect,"SELECT `tos` FROM `users` WHERE `username` = '$username'"); /* SELECT TOS COLUMN */

while ($row = mysqli_fetch_array($toschecker)) 
{
    $tos = $row['tos']; /* STORE TO A VARIABLE THE FETCHED TOS */
}

$unaccepted = 'unaccepted';

if ($tos == $unaccepted) /* COMPARE THE TOS VARIABLE IF UNACCEPTED */
{
    header('Location: accepttos.php');
}

else {
    header('Location: acceptedTOS.php'); /*  IF TOS IS ACCEPTED. CHANGE THE LOCATION */
}

mysqli_close($connect);

?>

$toschecker is a resource , try the following under the mysql_query line to see the result of your query, which you can use to redirect accepttos.php etc..

if( $row = mysql_fetch_assoc($toschecker)) {
    var_export($row['tos']);
}

You need to access the information in the fields of your database. Here is an example.

$toschecker = mysql_query($sql);

$row = mysql_fetch_array($toschecker);

$tos = $row['tos'];

if($tos == 'accepted'){
     // go to regular page
}else {
     // go to accept terms page
}