Jun 27, 2020 in PHP
Q: How can I prevent SQL injection in PHP?

1 Answer

0 votes
Jun 27, 2020

Use PDO and prepared queries.

($conn is a PDO object)

$stmt = $conn->prepare("INSERT INTO tbl VALUES(:id, :name)");
$stmt->bindValue(':id', $id);
$stmt->bindValue(':name', $name);
$stmt->execute();

Related questions

0 votes
Jun 22, 2019 in PHP
0 votes
Jun 23, 2019 in PHP
...