I want to know if the use of bindParam is mandatory to prevent SQL injection using PDO and MYSQL.
Example:
$username=$_POST['username'];
$password=$_POST['password'];
$cryptpass=hashFunction($password);
$sth=$dbh->prepare("INSERT INTO users(username,password) VALUES(?,?)");
$sth->execute(array($username,$cryptpass));
Is it a safe and proper way to write this code? Omitting bindParam makes shorter code.