I have a simple comment system, user inputs text into textarea
, a PHP script runs, checks if user is logged in, if submit is pressed and everything is filled out - it goes on inserting the data. My question is, what do I need to escape/trim/strip? Right now my query looks like this:
$sql = $con->prepare("INSERT INTO Comments (user, comment, pageid, time) VALUES (:user, :comment, :pageid, NOW())");
$sql->bindValue(":user", $user, PDO::PARAM_STR);
$sql->bindValue(":comment", $comment, PDO::PARAM_STR);
$sql->bindValue(":pageid", $pageid, PDO::PARAM_INT);
$sql->execute();
The variables come from the form using the POST
method. Is this secure to sql injection or do I need to do some extra trimming and escaping before inserting the data?