Anything wrong with this mysql?
Posted: Sat May 22, 2004 6:45 am
Hi
this always returns wrong username or password, it just wont work, i have rewrote the code many times following php books, websites, and it just wont work, hopefully you could spot whats wrong?

this always returns wrong username or password, it just wont work, i have rewrote the code many times following php books, websites, and it just wont work, hopefully you could spot whats wrong?
thanks so much to anybody who answers!<?
$user = "$username";
$pass = "$password";
$conn = mysql_connect("localhost","username","password");
$db = mysql_select_db("friedcpu");
$password = md5($pass);
$result = mysql_query("SELECT realname, username, password, email, url, country, datereg FROM users WHERE username='$user' and password='$pass'");
$myrow = mysql_fetch_array($result);
$real_username = $myrow["username"];
$real_password = $myrow["password"];
if ($user=="$real_username" && $pass=="$real_password") {
// Login Correct!
$cookie_user = $myrow["username"];
$cookie_pass = $myrow["password"];
$cookie_name = $myrow["realname"];
$cookie_email = $myrow["email"];
$cookie_url = $myrow["url"];
$cookie_country = $myrow["country"];
$cookie_datereg = $myrow["datereg"];
setcookie ("FriedCPU[username]", $cookie_user);
setcookie ("FriedCPU[pass]", $cookie_pass);
setcookie ("FriedCPU[name]", $cookie_name);
setcookie ("FriedCPU[email]", $cookie_email);
setcookie ("FriedCPU[url]", $cookie_url);
setcookie ("FriedCPU[country]", $cookie_country);
setcookie ("FriedCPU[datereg]", $cookie_datereg);
echo "Logged In As: $cookie_user";
}else{
echo "Wrong username or pass";
}
?>