Can anyone help me with this...

<?
if ($HTTP_POST_VARS["action"] == 1)
{
        checklogin($HTTP_POST_VARS["user_name"], $HTTP_POST_VARS["password"]);
        exit;
}

function checklogin($user_name, $password)
{
        login($user_name, $password);

        if ($sid != -1)
        {
                header("Location:
http://localhost/infekt/packages/imanager/index2.php?sid=$sid";);
        }
        else
        {
                header("Location: 
http://localhost/infekt/packages/imanager/index.php";);
        }
}

function login($user_name, $password)
{
        $db = "imanager";
        $SQL = "SELECT * FROM users WHERE user_name='".$user_name."' AND
password='".$password."'";
       # $connection = db_connect();

        $query = mysql_query('$SQL');

        if (mysql_num_rows($query) != 1)
        {
                return -1;
        }

        $row = mysql_fetch_array($query);

        $user_id = $row["user_id"];

        $sid = md5("blah blah".$user_id.$ttime);

        $remip = getenv ("REMOTE_ADDR");

        $ttime = date("YmdHis");

        $SQL2 = " INSERT INTO session ";
                $SQL2 = $SQL2 . " (user_id, sid, ttime, remip) VALUES ";
                $SQL2 = $SQL2 . " ('$user_id','$sid','$ttime','$remip') ";
        #######
        $result2 = mysql_db_query($db,"$SQL2",$connection);
        if (!$result2) { echo("ERROR: " . mysql_error() . "\n$SQL\n");
mysql_close($connection); exit; }
        #######
        SetCookie("iManager", "$user_id:$sid:$ip", time()+3600);

        return $sid;
}

?>

It is meant to check a user login from the same page POSTed back to it.
Fields being user_name and password.
When I try it I get an Error on Line 30:

if (mysql_num_rows($query) != 1)

Thankyou


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to