Por qué no coges usuario y contraseña a la vez?
Es decir, esto :
Código PHP:
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Nombre de usuario o contraseña incorrectas";
}else{
// the password was right!
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
Por esto otro:
Código PHP:
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username' and password='$password'") or die(mysql_error());
if (mysql_num_rows($info) == 0) {
// the password was not the user's password!
echo "Nombre de usuario o contraseña incorrectas";
}else{
// the password was right!
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
Así busca directamente usuarios que a la vez coincida con AMBOS campos; usuario y contraseña. Aunque no sé si eso solucionará tu problema.