i've written a functional login script using mysql however i've now been told that it need to be done using PDO, i've a functional PDO connection
function getConnection(){
$userName = '*****';
$password = '*****';
$dbname = '******';
$db = new PDO( "mysql:host=localhost;dbname=$dbname", $userName, $password );
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
return $db;
however i've no idea how to conver the login query to PDO
if (isset($_REQUEST['attempt']))
{
$user = $_POST['user'];
$password = $_POST['password'];
$qry = mysql_query
("SELECT *
FROM subscriber
WHERE email = '$user'
AND password = '$password'")
or die(mysql_error());
$total = mysql_num_rows($qry);
if ($total > 0)
{
session_start();
$_SESSION['user'] = 'yes';
header('location: account.php');
exit;
}
else
{
// do nothing.
}
}
any insight/help would be greatly appreciated thanks