From 227fc7fd20b1e0096ae89d7f60bae9c3a5a0632a Mon Sep 17 00:00:00 2001 From: Juan Date: Wed, 2 Feb 2022 11:15:35 +0100 Subject: [PATCH] =?UTF-8?q?bases=20de=20donn=C3=A9es=20suite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- b1-bak/session2/blog/admin.php | 15 ++++++--- b1-bak/session2/blog/commentaire.sql | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 b1-bak/session2/blog/commentaire.sql diff --git a/b1-bak/session2/blog/admin.php b/b1-bak/session2/blog/admin.php index 51463df..d5e8893 100644 --- a/b1-bak/session2/blog/admin.php +++ b/b1-bak/session2/blog/admin.php @@ -42,15 +42,22 @@ echo "
Il manque quelque chose !
"; } elseif(!empty($titre_de_article)) { - $resultat = $mysqli->query(" - INSERT INTO `article` (`id_article`, `titre`, `contenu`, `date`) - VALUES (NULL, '".$titre_de_article."', '".$contenu_de_article." ', NOW()); - "); + $sql = "INSERT INTO `article` (`id_article`, `titre`, `contenu`, `date`) + VALUES (NULL, ?, ?, NOW()); "; + $requete = $mysqli->prepare($sql); + //https://www.php.net/manual/en/mysqli-stmt.bind-param.php + $requete->bind_param('ss',$titre_de_article,$contenu_de_article); + $resultat = $requete->execute(); + if($resultat) { echo "
Article enregistré !
"; $titre_de_article = ""; $contenu_de_article = ""; } + else { + echo "Error description: " . $mysqli -> error; + echo $sql; + } } ?>
diff --git a/b1-bak/session2/blog/commentaire.sql b/b1-bak/session2/blog/commentaire.sql new file mode 100644 index 0000000..4225059 --- /dev/null +++ b/b1-bak/session2/blog/commentaire.sql @@ -0,0 +1,61 @@ +-- phpMyAdmin SQL Dump +-- version 5.1.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Feb 02, 2022 at 11:14 AM +-- Server version: 10.4.22-MariaDB +-- PHP Version: 7.4.27 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `b1bak` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `commentaire` +-- + +CREATE TABLE `commentaire` ( + `id_comentaire` int(11) NOT NULL, + `article_id` int(11) NOT NULL, + `pseudo` varchar(255) NOT NULL, + `mail` varchar(255) NOT NULL, + `commentaire` text NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `commentaire` +-- +ALTER TABLE `commentaire` + ADD PRIMARY KEY (`id_comentaire`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `commentaire` +-- +ALTER TABLE `commentaire` + MODIFY `id_comentaire` int(11) NOT NULL AUTO_INCREMENT; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;