mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 11:43:16 +02:00
🔒️ getTheseByAuthor() now sanitize author name
This commit is contained in:
@@ -24,12 +24,18 @@ class dump {
|
|||||||
|
|
||||||
$pdo_obj = new conf();
|
$pdo_obj = new conf();
|
||||||
$pdo = $pdo_obj->getPDO();
|
$pdo = $pdo_obj->getPDO();
|
||||||
$stmt = $pdo->query("SELECT * FROM theses WHERE author LIKE '%$author%';");
|
|
||||||
|
$author = '%' . $author . '%';
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM theses WHERE author LIKE :author;");
|
||||||
|
$stmt->bindParam(':author', $author, PDO::PARAM_STR, 100);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($obj = $stmt->fetchObject()) {
|
while ($obj = $stmt->fetchObject()) {
|
||||||
$theses_array[$i] = array();
|
$theses_array[$i] = array();
|
||||||
foreach ($obj as $elem) {
|
foreach ($obj as $elem) {
|
||||||
array_push($theses_array[$i], empty($elem) ? "NULL" : $elem);
|
array_push($theses_array[$i], empty($elem) ? "Non définit" : $elem);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user