From 23e26a287ce61d658ac742f01c65f0d290ebf257 Mon Sep 17 00:00:00 2001 From: Jan BELLON Date: Thu, 7 Mar 2024 01:25:36 +0000 Subject: [PATCH] Update 3 files - /html/journal.php - /html/login.php - /html/upload.php --- html/journal.php | 2 +- html/login.php | 2 +- html/upload.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/html/journal.php b/html/journal.php index 07b57dff..c67f61e8 100644 --- a/html/journal.php +++ b/html/journal.php @@ -55,7 +55,7 @@ if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) { $bdd = connect($dbhost, $dbname, $dbuser, $dbpass); $req = $bdd->prepare("SELECT (ID, titre, date, auteur) FROM articles ORDER BY date DESC"); $bdd->execute(); - $resultat = $req->fetch(PDO::FETCH_ASSOC); + $resultat = $req->fetchAll(PDO::FETCH_ASSOC); if ($resultat) { foreach($resultat as $row) { diff --git a/html/login.php b/html/login.php index e41f8456..668ea933 100644 --- a/html/login.php +++ b/html/login.php @@ -16,7 +16,7 @@ if(isset($_POST['username']) && isset($_POST['password'])) { $bdd->bindParam(':password', md5($_POST['password'])); $bdd->execute(); - $resultat = $req->fetch(PDO::FETCH_ASSOC); + $resultat = $req->fetchAll(PDO::FETCH_ASSOC); if ($resultat) { $_SESSION['username'] = $resultat[0]['username']; diff --git a/html/upload.php b/html/upload.php index 41f19f96..2a0903ca 100644 --- a/html/upload.php +++ b/html/upload.php @@ -11,7 +11,7 @@ if(isset($_POST['title']) && isset($_FILES['file'])) { $filename = date("YmdHis"); $destination = "../content/journal/" . $filename; $bdd = connect($dbhost, $dbname, $dbuser, $dbpass); - $insertcred = $bdd->prepare("INSERT INTO articles (ID, titre, date, auteur) VALUES (:filename, :titre, :date, :auteur)"); + $upload = $bdd->prepare("INSERT INTO articles (ID, titre, date, auteur) VALUES (:filename, :titre, :date, :auteur)"); $bdd->bindParam(':filename', $filename); $bdd->bindParam(':titre', htmlspecialchars($_POST['titre'])); $bdd->bindParam(':auteur', $_SESSION['display_name']); @@ -20,7 +20,7 @@ if(isset($_POST['title']) && isset($_FILES['file'])) { } else { $bdd->bindParam(':date', date()); } - $insertcred->execute(); + $upload->execute(); move_uploaded_file($_FILES['file']['tmp_name'], $destination); }