I am trying to authenticate users with this script. The problem is that it needs to check the value in the confirm field (it needs to equal 0 in order for them to login), here is what I have so far:
<?php
if ((!$username) || (!$password)) { echo ("Please fill out both entries."); exit;}
else {
$db_name="tempagencyreviews";
$table_name="temp_user";
$connection = @mysql_connect("localhost", "xxxxx", "xxxxxx") or die ("Couldn't connect.");
$db= @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "SELECT confirmed FROM temp_user WHERE username = '$username'";
$result = mysql_query("select confirmed from temp_user where username='$username'");
if (!$result)
return "Could not execute query";
if ($confirmed='1') {
print "Your account has not been confirmed. <a href=\"/users/reconfirm.php\">Go here</a>";
exit;
} else
{$sql="select * from temp_user where username="$username" and password="$password"";
$result = @($sql,$connection) or die "Couldn't execute query.");
$num = mysql_numrows($result);
if ($num=0) { $msg = "<p> Congratulations, you're authorized!</p>";} else {
echo "We were not able to authenticate your username. Did you forget your password
and username? <a href=\"/users/retrieve.php\">Retrieve it here</a>. "; exit; }
?>
What am I doing wrong?
thanks..