is "$HTTP__Host" just a typo?

it should be $HTTP_HOST.

Cheers,
Maxim Maletsky

-----Original Message-----
From: Jamie [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 23, 2001 11:41 AM
To: PHP
Subject: [PHP] Function with True / False return


can anyone tell me whats wrong with this function:

function AuthenticateUser($user, $password)
{
global $DB_Server, $HTTP__Host, $DB_Login, $DB_Password, $DB_Name, $DocRoot
;
// Open a connection with the MySQl server
if (!($link = mysql_connect ($DB_Server,$DB_Login, $DB_Password))) {
DisplayErrMessage(sprintf("internal error %s %s %s %d:%s\n",$DB_Server,
$DB_Login, $DB_Password,
mysql_errno(), mysql_error()));
return 0 ;
}
// Do the user/password authentication via attempted update of stats
if (!($result = mysql_db_query($DB_Name,"UPDATE users SET visits='4' WHERE
user_id='$user' AND password='$password'")))
return 0;
else
return 1;
}


code that references the above function
if (AuthenticateUser($form_user_id, $form_password)){
setcookie("cookie_passwd",$form_password);
setcookie("cookie_user",$form_user_id);
header("Location:http://$HTTP_Host/$DocRoot/default_authenticated.php");
exit();
} else {
header("Location:http://$HTTP_Host/$DocRoot/error.php?type=badpass");
exit() ;
}

It's ment to test the validity of a login attempt with a user and passoword
by updateing the colum visits to a new value. But weather or not this update
passes or fails the return value seems to be 1 as the page is rediredted to
the logged in page.
Also can I update the visits value in the SQL command I've tried
visits=visits+1 but that does not seem to work even though I have seen this
done with a $variable instead of the value one.
Any help would be appreciated.
Jamie


-- 
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]

-- 
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