hello i am relatively new to pdo(php) and i created a basic login system i know it is not secure yet but i am just experimenting anyway i know in the old php you could echo out and error message within an if statement but it does not seem to work anymore here is my script is it that im doing something wrong or that you just cant do that in pdo anymore.
if ($row == null){
header( "location: login.html");
echo "login failed";
} else{
header("location: homepage.php");
}
i realize that this may not have enough code available so here is the rest of the script
session_start();
//connection String
$connection = new PDO("sqlsrv:server=server;Database=database", "username", "password");
//Seelcting function
$smt = $connection->prepare("select user_id, username from account where username = :username and password =:password");
//setting values to textboxes
$username = $_POST["txt_username"];
$password = $_POST["txt_password"];
//binding values
$smt->bindValue(':username', $username);
$smt->bindValue(':password', $password);
//execution
$smt->execute();
//fetching data
$row = $smt->fetch( PDO::FETCH_ASSOC ) ;
echo "$row[user_id]\n\n";
echo "$row[username]\n\n";
$_SESSION{"user_id"} = $row["user_id"];