Why does this php not work for my login?

Jonathan H

New member
if (count($_POST) > 0) {

include("dbconnection.php");

$username = $_POST["username"];
$password = $_POST["password"];

$qry = mysql_query("SELECT * FROM users WHERE ('username' = $username)") or die(mysql_error());

$data = mysql_fetch_array($qry, MYSQL_ASSOC);

if (mysql_num_rows($data) > 0){

if ($data['password'] == $password){
$_SESSION["logged"] =true;
header("location:profile.php");
}else {
$output .="<li class><p> Your Password/Username was wrong.<br /> Please try again.</p></li>";
}
}else {
$output .="<li class><p> Your Password/Username was wrong.<br /> Please try again.</p></li>";
}

}else {
$output .="<li class><p>Please Sign in Below</p></li>";
}
print $output;
 
Back
Top