Hi,
i have a form with 2 fields (username, userpassword). Once the user click submit, the username and password should be verified on my database and then a cookie assigned. However, $value is always = 0 when the script runs.
Here is the code...
function login() {
global $dbhost, $dbname, $dbusername, $dbpassword, $admin_table, $username, $userpassword;
db_connect();
print ("<p><font class='bodyfont' size='2'>$username, $userpassword, $admin_table</font></p>\n");
$SQL = "SELECT * FROM $admin_table WHERE user_id ='$username'";
$query = mysql_query($SQL);
$row = mysql_fetch_array($query);
if (($row["user_id"] == $username)
AND ($row["password"] == $userpassword)
AND ($username != "")){
$user_id = $row["user_id"];
$md5pw = md5($userpassword);
SetCookie("TheLoginCookie", "$user_id:$md5pw", time()+3600);
$value = 1;
else {
$value = 0;
f }
return $value;
}
Can anyone help?