Nie możesz mieszać PDO i mysql .. Tworzysz zapytanie w PDO
i używając mysql_*
Spróbuj zmienić kod na
<?php
// Inialize session
session_start();
// Include database connection settings
include('../../model/database.php');
// Retrieve username and password from database according to user's input
$stmt = $db->prepare("SELECT * FROM user WHERE (`username` = :username) and (`password` = :password)");
$result = $stmt->execute(array(':username'=>$_POST['username'],':password'=>$_POST['password']));
$num_rows = $stmt->rowCount();
// Check username and password match
if ( $num_rows > 0) {
// Set username session variable
$_SESSION['username'] = $_POST['username'];
// Jump to secured page
header('Location: securedpage.php');
}
else {
// Jump to login page
header('Location: index.php');
}
?>
zobacz reference