hi guys i'm new with php and mysql, i am currently trying to check the user input &username if there's already existing the same username in the database, and same with user input $email.
i have below codes, i tried having a line that echoes and compares user input against fetch rows/ data from database. I was able to verify that it reaches to the point where line echo $email."COMPARE".$result2; is both the same, yet it passes the condition $email == $result2 where result2 is email fetch from database. Can you please point me what's wrong? THanks in advance.
$extract= mysql_query("SELECT * FROM users");
$resultq = mysql_num_rows($extract);
while($row= mysql_fetch_array($extract))
{
$result = $row['username'];
$result2 = $row['email'];
echo $email."COMPARE".$result2;
if($username == $result)
{
echo "<script type=\"text/javascript\">alert('Username Already Taken')</script>";
echo "<meta http-equiv=\"refresh\" content=\"0;url=6signup.html\" />";
break;
}
else if ($email == $result2)
{
echo "<script type=\"text/javascript\">alert('Email Already Registered')</script>";
echo "<meta http-equiv=\"refresh\" content=\"0;url=6signup.html\" />";
break;
}
else
{
//continues to execute the loop until no more to fetch
}