Skip to content
Snippets Groups Projects
Commit 462ad3c5 authored by Giildo's avatar Giildo
Browse files

:sparkles: Cours du 26/02/2024

parent 6266edfe
Branches
No related merge requests found
......@@ -71,6 +71,10 @@ html {
width: 100%;
height: 494px;
background-color: var(--decoration-color-bg);
&.plus {
background-color: red;
}
}
}
}
\ No newline at end of file
export const button = document.querySelector('button');
button.addEventListener('click', function () {
const main = document.querySelector('main')
for (let i = 0; i < 6; i++) {
const article = document.createElement('article')
main.appendChild(article)
}
const articles = document.querySelectorAll('main article');
articles.forEach((article) => {
article.classList.add('plus')
})
});
\ No newline at end of file
File added
<?php
$username = htmlspecialchars($_POST['username']);
$message = htmlspecialchars($_POST['message']);
// var_dump => pour débuguer
if ($message !== '' && $username !== '' && strlen($username) < 100) {
$pdo = new PDO("sqlite:" . __DIR__ . "/database.sqlite");
$pdo->query('CREATE TABLE IF NOT EXISTS message (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username VARCHAR(100) NOT NULL,
message TEXT NOT NULL
)');
$stmt = $pdo->prepare("INSERT INTO message ('username', 'message') VALUES (:username, :message)");
$stmt->bindValue(':username', $username);
$stmt->bindValue(':message', $message);
$stmt->execute();
header('Location: /recette.php');
}
\ No newline at end of file
......@@ -7,6 +7,7 @@
<title>Document</title>
<link rel="stylesheet" href="/assets/css/style.css"/>
<script src="assets/js/script.js" type="module"></script>
</head>
<body>
<nav>
......@@ -22,9 +23,10 @@
</ul>
</nav>
<section>
<img src="assets/img/meat.png" alt="" />
<img src="assets/img/logo2.svg" alt="" />
<img src="assets/img/meat.png" alt=""/>
<img src="assets/img/logo2.svg" alt=""/>
</section>
<main>
<h1>Nos recettes</h1>
<article></article>
......@@ -34,6 +36,9 @@
<article></article>
<article></article>
</main>
<button>Voir plus d'article</button>
<footer></footer>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Recette</title>
</head>
<body>
<!--
La recette
-->
<form action="assets/php/form.php" method="post">
<label for="username">Votre nom de zombie *</label>
<input type="text" id="username" name="username"/>
<label for="message">Message</label>
<textarea id="message" name="message"></textarea>
<button type="submit">Envoyer le message</button>
</form>
<?php
$pdo = new PDO("sqlite:" . __DIR__ . "/assets/php/database.sqlite");
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$comments = $pdo->query('SELECT * FROM message')
->fetchAll();
foreach ($comments as $comment) {
?>
<article>
<ul>
<li><?php echo $comment['id'] ?></li>
<li><?= $comment['username'] ?></li>
<li><?= $comment['message'] ?></li>
</ul>
</article>
<?php
}
?>
</body>
</html>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment