This code, below is supposed to check the database for the user level, if the level = 1, this would be given the admin cookie. If the level = 0 , this would get given the user cookie, but i can't get it to work.

If anyone knows it would really help.
 PHP:

<?php

include '../includes/db_connect.php';
include '../includes/config_table.inc.php';


$user_name = $_POST["user_name"];        
$user_password = $_POST["user_password"];    

if ($user_name && $user_password)        
{

$salt = substr($user_password, 0, 2);
$userPswd = crypt($user_password, $salt);
$login_check = mysql_num_rows(mysql_query("SELECT * FROM `$user` WHERE user_name='$user_name' AND user_password='$userPswd'" ));
    $check_ad = mysql_query("SELECT * FROM `$user` WHERE userlevel = '0'");
    $check_us = mysql_query("SELECT * FROM `$user` WHERE userlevel = '1");

    if ($login_check == 1 && $check_ad)    
    {
    echo "Logged In Sucessfully. Please wait while you are redirected";    
echo "<meta http-equiv='refresh' content='2; url=setadmincookie.php?&u=$username&p=$user_password'>";
    }
    
    else
    if ($login_check == 1 && $check_us)    
    {        
        echo "Logged In Sucessfully. Please wait while you are redirected";    
echo "<meta http-equiv='refresh' content='2; url=setcookie.php?&u=$username&p=$user_password'>";
    }
    
    else
    {
        echo 'Login failed. Username and Password did not match database entries.';    
    }
}

else    
{
    echo "Form was not completed. Please go back and make sure that the form was fully completed.";    
}


mysql_close();

?>




My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"