modification de la connexion et ajout de catégorie et articles
This commit is contained in:
57
blog/categories/ajouter_categorie.html
Normal file
57
blog/categories/ajouter_categorie.html
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Ajouter une catégorie</title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body{
|
||||||
|
background: #f4f6f9;
|
||||||
|
|
||||||
|
}
|
||||||
|
.container{
|
||||||
|
max-width: 600px;
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="mb-4 text-center">Ajouter une catégorie</h2>
|
||||||
|
|
||||||
|
<!--Erreur champ vide -->
|
||||||
|
<div id="errorEmpty" class="alert alert-danger d-none">Le nom de catégorie est obligatoire.</div>
|
||||||
|
|
||||||
|
<!--Erreur nom deja existant -->
|
||||||
|
<div id="errorExists" class="alert alert-danger d-none">Cette catégorie existe déjà. Veuillez en choisir une autre.</div>
|
||||||
|
|
||||||
|
<!--Succès ajout catégorie -->
|
||||||
|
<div id="successMessage" class="alert alert-success d-none">Catégorie ajoutée avec succès !</div>
|
||||||
|
|
||||||
|
<form id="addCategoryForm">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Nom de la catégorie *</label>
|
||||||
|
<input type="text" id="categoryName" class="form-control" placeholder="Actualité, chien, chat .." required></div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Description</label>
|
||||||
|
<textarea id="categoryDescription" class="form-control" rows="4" placeholder="Entrez une description (optionnel)"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-3 mt-4">
|
||||||
|
<a href="liste_categories.html" class="btn btn-danger w-50">Annuler</a>
|
||||||
|
<button type="submit" class="btn btn-primary w-50">Ajouter</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="ajouter.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
42
blog/categories/ajouter_categorie.js
Normal file
42
blog/categories/ajouter_categorie.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
const form = document.getElementById("addCategoryForm");
|
||||||
|
const nameField = document.getElementById("categoryName");
|
||||||
|
const descField = document.getElementById("categoryDescription");
|
||||||
|
|
||||||
|
const errorEmpty = document.getElementById("errorEmpty");
|
||||||
|
const errorExists = document.getElementById("errorExists");
|
||||||
|
const successMessage = document.getElementById("successMessage");
|
||||||
|
|
||||||
|
// Catégories existantes ( à remplacer en BD si besoin)
|
||||||
|
const existingCategories = ["Actualités", "Chien", "Chat", "Boutique"];
|
||||||
|
|
||||||
|
form.addEventListener("submit", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const nom = nameField.value.trim();
|
||||||
|
|
||||||
|
//Remettre tout a zero
|
||||||
|
errorEmpty.classList.add("d-none");
|
||||||
|
errorExists.classList.add("d-none");
|
||||||
|
successMessage.classList.add("d-none");
|
||||||
|
|
||||||
|
//Erreur champs vide
|
||||||
|
if (nom === "") {
|
||||||
|
errorEmpty.classList.remove("d-none");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Erreur catégorie existante
|
||||||
|
if (existingCategories.includes(nom)) {
|
||||||
|
errorExists.classList.remove("d-none");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Succès
|
||||||
|
successMessage.classList.remove("d-none");
|
||||||
|
|
||||||
|
|
||||||
|
//Ajout d'une nouvelle catégorie en BDD
|
||||||
|
categoriesExistantes.push(nom);
|
||||||
|
|
||||||
|
});
|
||||||
87
blog/categories/articles/ajouter_article.html
Normal file
87
blog/categories/articles/ajouter_article.html
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Ajouter un article</title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: #f4f6f9;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 700px;
|
||||||
|
margin: 40px auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="mb-4 text-center">Ajouter un article</h2>
|
||||||
|
|
||||||
|
<!--Erreur titre vide-->
|
||||||
|
<div id="errorEmpty" class="alert alert-danger d-none">Le titre de l'article est obligatoire</div>
|
||||||
|
|
||||||
|
<!--Erreur image invalide-->
|
||||||
|
<div id="errorImage" class="alert alert-danger d-none">
|
||||||
|
Format d'image invalide. Formats acceptés : JPG, PNG
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Erreur titre existant-->
|
||||||
|
<div id="errorExists" class="alert alert-danger d-none">Ce titre existe déjà. Choisissez un autre titre.</div>
|
||||||
|
|
||||||
|
<!--Succès ajout article-->
|
||||||
|
<div id="successMsg" class="alert alert-success d-none">Article ajouté avec succès !</div>
|
||||||
|
|
||||||
|
<!--Image-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Image de l'article</label>
|
||||||
|
<input type="file" id="articleImage" class="form-control" accept="image/*">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Titre-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Titre de l'article *</label>
|
||||||
|
<input type="text" id="articleTitle" class="form-control" placeholder="Entrez le titre de l'article">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Contenu-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Contenu de l'article</label>
|
||||||
|
<textarea id="articleContent" class="form-control" rows="5" placeholder="Entrez le contenu de l'article"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Catégorie-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Catégorie de l'article</label>
|
||||||
|
<select id="articleCategory" class="form-select">
|
||||||
|
<option value="" selected disabled>Choisissez une catégorie</option>
|
||||||
|
<option value="actualités">Actualités</option>
|
||||||
|
<option value="chien">Chien</option>
|
||||||
|
<option value="chat">Chat</option>
|
||||||
|
<option value="boutique">Boutique</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Publié-->
|
||||||
|
<div class="form-check mb-3">
|
||||||
|
<input class="form-check-input" type="checkbox" id="articlePublished">
|
||||||
|
<label class="form-check-label">Publié</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Boutons-->
|
||||||
|
<div class="d-flex gap-3 mt-4">
|
||||||
|
<a href="liste_articles.html" class="btn btn-danger w-50">Annuler</a>
|
||||||
|
<button type="submit" class="btn btn-primary w-50">Ajouter</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="ajouter_article.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
55
blog/categories/articles/ajouter_article.js
Normal file
55
blog/categories/articles/ajouter_article.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
const form = document.getElementById('addArticleForm');
|
||||||
|
const imgField = document.getElementById('articleImage');
|
||||||
|
const titleField = document.getElementById('articleTitle');
|
||||||
|
const contentField = document.getElementById('articleContent');
|
||||||
|
const categoryField = document.getElementById('articleCategory');
|
||||||
|
const publishedField = document.getElementById('articlePublished');
|
||||||
|
|
||||||
|
const errorEmpty = document.getElementById('errorEmpty');
|
||||||
|
const errorImage = document.getElementById('errorImage');
|
||||||
|
const errorExists = document.getElementById('errorExists');
|
||||||
|
const successMsg = document.getElementById('successMsg');
|
||||||
|
|
||||||
|
// Simulation BDD
|
||||||
|
const titreExistants = ['décoration noel', 'coupe de chien'];
|
||||||
|
|
||||||
|
form.addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const titre = titleField.value.trim() .toLowerCase();
|
||||||
|
const fichierImage = imgField.files[0];
|
||||||
|
|
||||||
|
// Reset messages
|
||||||
|
errorEmpty.classList.add('d-none');
|
||||||
|
errorImage.classList.add('d-none');
|
||||||
|
errorExists.classList.add('d-none');
|
||||||
|
successMsg.classList.add('d-none');
|
||||||
|
|
||||||
|
// Titre obligatoire
|
||||||
|
if (titre === "") {
|
||||||
|
errorEmpty.classList.remove('d-none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Titre déjà existant
|
||||||
|
if (titreExistants.includes(titre)) {
|
||||||
|
errorExists.classList.remove('d-none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Image invalide
|
||||||
|
if (fichierImage) {
|
||||||
|
const validFormats = ['image/jpeg', 'image/png'];
|
||||||
|
if (!validFormats.includes(fichierImage.type)) {
|
||||||
|
errorImage.classList.remove('d-none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Succès
|
||||||
|
successMsg.classList.remove('d-none');
|
||||||
|
|
||||||
|
// Simuler enregistrement
|
||||||
|
titreExistants.push(titre);
|
||||||
|
|
||||||
|
});
|
||||||
127
blog/categories/articles/modifier_article.html
Normal file
127
blog/categories/articles/modifier_article.html
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Modifier un article</title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: #f4f6f9;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 700px;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
.preview-img {
|
||||||
|
max-width: 15Opx;
|
||||||
|
border-radius: 8px
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="mb-4 text-center">Modifier un article</h2>
|
||||||
|
|
||||||
|
<!--Erreur titre vide-->
|
||||||
|
<div id="errorEmpty" class="alert alert-danger d-none">
|
||||||
|
❌ Le titre de l'article est obligatoire.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Erreur image invalide-->
|
||||||
|
<div id="errorImage" class="alert alert-danger d-none">
|
||||||
|
Format d'image invalide. Formats acceptés : JPG, PNG, GIF.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Erreur titre existant-->
|
||||||
|
<div id="errorExists" class="alert alert-danger d-none">
|
||||||
|
Ce titre existe déjà. Veuillez en choisir un autre.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Succès-->
|
||||||
|
<div id="successMsg" class="alert alert-success d-none">
|
||||||
|
L'article a été modifié avec succès !
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Formulaire -->
|
||||||
|
<form id="editArticleForm">
|
||||||
|
|
||||||
|
<!-- Image actuelle -->
|
||||||
|
<label class="fw-bold">Image actuelle</label>
|
||||||
|
<div class="mb-3">
|
||||||
|
<img src="images/article1.jpg" alt="Image actuelle" class="preview-img mb-2">
|
||||||
|
<input type="file" id="articleImage" class="form-control" accept="image/*">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Titre-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Titre de l'article *</label>
|
||||||
|
<input type="text" id="articleTitle" class="form-control" value="Titre de l'article actuel" placeholder="Modifier le titre">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Contenu-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Contenu de l'article</label>
|
||||||
|
<textarea id="articleContent" class="form-control" rows="5">Contenu de l'article actuel...</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Catégorie-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Catégorie de l'article</label>
|
||||||
|
<select id="articleCategory" class="form-select">
|
||||||
|
<option value="actualités">Actualités</option>
|
||||||
|
<option value="chien">Chien</option>
|
||||||
|
<option value="chat">Chat</option>
|
||||||
|
<option value="boutique">Boutique</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Publié-->
|
||||||
|
<div class="form-check mb-3">
|
||||||
|
<input class="form-check-input" type="checkbox" id="articlePublished" checked>
|
||||||
|
<label class="form-check-label">Publié</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Boutons-->
|
||||||
|
<div class="d-flex gap-3 mt-4">
|
||||||
|
<a href="liste_articles.html" class="btn btn-danger w-50">Annuler</a>
|
||||||
|
<button type="submit" class="btn btn-primary w-50">Enregistrer</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="modifier_article.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
66
blog/categories/articles/modifier_article.js
Normal file
66
blog/categories/articles/modifier_article.js
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
const form = document.getElementById('editArticleForm');
|
||||||
|
const imgField = document.getElementById('articleImage');
|
||||||
|
const titleField = document.getElementById('articleTitle');
|
||||||
|
const contentField = document.getElementById('articleContent');
|
||||||
|
const categoryField = document.getElementById('articleCategory');
|
||||||
|
const publishedField = document.getElementById('articlePublished');
|
||||||
|
|
||||||
|
const errorEmpty = document.getElementById('errorEmpty');
|
||||||
|
const errorImage = document.getElementById('errorImage');
|
||||||
|
const errorExists = document.getElementById('errorExists');
|
||||||
|
const successMsg = document.getElementById('successMsg');
|
||||||
|
|
||||||
|
// Simulation BDD pour vérifier doublons
|
||||||
|
const titresExistants = [
|
||||||
|
"article de test",
|
||||||
|
"nouveautés chiens",
|
||||||
|
"actualité du mois"
|
||||||
|
];
|
||||||
|
|
||||||
|
form.addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const titre = titleField.value.trim().toLowerCase();
|
||||||
|
const fichierImage = imgField.files[0];
|
||||||
|
|
||||||
|
// Reset messages
|
||||||
|
errorEmpty.classList.add('d-none');
|
||||||
|
errorImage.classList.add('d-none');
|
||||||
|
errorExists.classList.add('d-none');
|
||||||
|
successMsg.classList.add('d-none');
|
||||||
|
|
||||||
|
//Titre obligatoire
|
||||||
|
if (titre === "") {
|
||||||
|
errorEmpty.classList.remove('d-none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Titre déjà existant ?
|
||||||
|
if (titresExistants.includes(titre)) {
|
||||||
|
errorExists.classList.remove('d-none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Vérification image
|
||||||
|
if (fichierImage) {
|
||||||
|
const validFormats = ['image/jpeg', 'image/png', 'image/gif'];
|
||||||
|
if (!validFormats.includes(fichierImage.type)) {
|
||||||
|
errorImage.classList.remove('d-none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Succès
|
||||||
|
successMsg.classList.remove('d-none');
|
||||||
|
|
||||||
|
console.log("Article modifié :", {
|
||||||
|
titre,
|
||||||
|
contenu: contentField.value,
|
||||||
|
categorie: categoryField.value,
|
||||||
|
publie: publishedField.checked,
|
||||||
|
image: fichierImage ? fichierImage.name : "Image inchangée"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
61
blog/categories/modifier_categorie.html
Normal file
61
blog/categories/modifier_categorie.html
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Modifier une catégorie</title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: #f4f6f9;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 50px auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="mb-4 text-center">Modifier une catégorie</h2>
|
||||||
|
|
||||||
|
<div id="errorMsg" class="alert alert-danger d-none">Veuillez ezmplir tous les champs obligatoires</div>
|
||||||
|
|
||||||
|
<div id="successMsg" class="alert alert-success d-none">La catégorie a été modifiée avec succès !</div>
|
||||||
|
|
||||||
|
<form id="modifierCategorie">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Nom de la catégorie *</label>
|
||||||
|
<select id="categoryName" class="form-select" required>
|
||||||
|
<option value="" selected disabled>— Choisir une catégorie —</option>
|
||||||
|
<option value="actualité">Actualité</option>
|
||||||
|
<option value="chien">Chien</option>
|
||||||
|
<option value="chat">Chat</option>
|
||||||
|
<option value="boutique">Boutique</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold">Description *</label>
|
||||||
|
<textarea id="categorieDescription" class="form-control" rows="4" placeholder="Entrez une description" required></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-3 mt-4">
|
||||||
|
<a href="liste_categories.html" class="btn btn-danger w-50">Annuler</a>
|
||||||
|
<button type="submit" class="btn btn-primary w-50">Enregistrer</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
22
blog/categories/modifier_categorie.js
Normal file
22
blog/categories/modifier_categorie.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
const form = document.getElementById("modifierCatgorie");
|
||||||
|
const nameField = document.getElementById("nomCategorie");
|
||||||
|
const descField = document.getElementById("categorieDescription");
|
||||||
|
const errorMsg = document.getElementById("errorMsg");
|
||||||
|
const successMsg = document.getElementById("successMsg");
|
||||||
|
|
||||||
|
form.addEventListener("submit", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
//vérification des champs obligatoires
|
||||||
|
if (nameField.value.trim() === "" || descField.value.trim() === "") {
|
||||||
|
errorMsg.classList.remove("d-none");
|
||||||
|
successMsg.classList.add("d-none");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Succès
|
||||||
|
errorMsg.classList.add("d-none");
|
||||||
|
successMsg.classList.remove("d-none");
|
||||||
|
|
||||||
|
});
|
||||||
55
connexion/mot_de_passe_oublie/mot_de_passe_oublie.html
Normal file
55
connexion/mot_de_passe_oublie/mot_de_passe_oublie.html
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Mot de passe oublié</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: #f2f4f7;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.forgot-password-card {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 380px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="card shadow forgot-password-card">
|
||||||
|
<div class="card-body p-4">
|
||||||
|
<h3 class="text-center mb-4">Mot de passe oublié</h3>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Adresse e-mail</label>
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="exemple@mail.com"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn btn-primary w-100">
|
||||||
|
Réinitialiser le mot de passe
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="text-center mt-3">
|
||||||
|
<a href="page_de_connexion.html" class="text-decoration-none"
|
||||||
|
>Retour à la connexion</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Connexion Admin</title>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
|
||||||
<style>
|
|
||||||
body{
|
|
||||||
background: #f2f4f7;
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-card {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 380px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="card shadow login-card">
|
|
||||||
<div class="card-body p-4">
|
|
||||||
<h3 class="text-center mb-4">Connexion Admin</h3>
|
|
||||||
|
|
||||||
|
|
||||||
<form>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Mot de passe</label>
|
|
||||||
<input type="password" class="form-control" placeholder="••••••••">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="btn btn-primary w-100">Se connecter</button>
|
|
||||||
|
|
||||||
<div class="text-center mt-3">
|
|
||||||
<a href="#" class="text-decoration-none">Mot de passe oublié ?</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
51
connexion/page_de_connexion/page_de_connexion.html
Normal file
51
connexion/page_de_connexion/page_de_connexion.html
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Connexion Admin</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
|
||||||
|
/>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: #f2f4f7;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 380px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="card shadow login-card">
|
||||||
|
<div class="card-body p-4">
|
||||||
|
<h3 class="text-center mb-4">Connexion Admin</h3>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Mot de passe</label>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="••••••••"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn btn-primary w-100">Se connecter</button>
|
||||||
|
|
||||||
|
<div class="text-center mt-3">
|
||||||
|
<a href="#" class="text-decoration-none">Mot de passe oublié ?</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
const form = document.getElementById('resetForm');
|
||||||
|
const password = document.getElementById('password');
|
||||||
|
const confirmPassword = document.getElementById('confirmPassword');
|
||||||
|
const errorMsg = document.getElementById('errorMsg');
|
||||||
|
const successMsg = document.getElementById('successMsg');
|
||||||
|
|
||||||
|
const minLength = 8;
|
||||||
|
|
||||||
|
form.addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Réinitialisation des messages
|
||||||
|
errorMsg.style.display = 'none';
|
||||||
|
successMsg.style.display = 'none';
|
||||||
|
|
||||||
|
const pass = password.value.trim();
|
||||||
|
const confirm = confirmPassword.value.trim();
|
||||||
|
|
||||||
|
//Longueur minimale
|
||||||
|
if (pass.length < minLength) {
|
||||||
|
errorMsg.style.display = 'block';
|
||||||
|
errorMsg.textContent = `Le mot de passe doit contenir au moins ${minLength} caractères.`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Correspondance
|
||||||
|
if (pass !== confirm) {
|
||||||
|
errorMsg.style.display = 'block';
|
||||||
|
errorMsg.textContent = 'Les mots de passe ne correspondent pas.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Succès
|
||||||
|
successMsg.style.display = 'block';
|
||||||
|
successMsg.textContent = 'Mot de passe réinitialisé avec succès !';
|
||||||
|
});
|
||||||
|
|
||||||
@@ -28,12 +28,16 @@
|
|||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<h3 class="text-center mb-4">Nouveau mot de passe</h3>
|
<h3 class="text-center mb-4">Nouveau mot de passe</h3>
|
||||||
<p class="text-center text-muted mb-4">
|
<p class="text-center text-muted mb-4">
|
||||||
Entrez votre nouveau mot de passe et confirmez-le.
|
Pour réinitialiser votre mot de passe, veuillez saisir un nouveau mot
|
||||||
|
de passe ainsi qu'une confirmation. Le mot de passe doit contenir au
|
||||||
|
minimum 8 caractères.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form id="resetForm">
|
<form id="resetForm">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Nouveau mot de passe</label>
|
<label class="form-label"
|
||||||
|
>Nouveau mot de passe (minimum 8 caractères)</label
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@@ -43,7 +47,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Confirmer le mot de passe</label>
|
<label class="form-label"
|
||||||
|
>Confirmer le mot de passe (minimum 8 caractères)</label
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@@ -57,7 +63,7 @@
|
|||||||
class="alert alert-danger text-center"
|
class="alert alert-danger text-center"
|
||||||
style="display: none"
|
style="display: none"
|
||||||
>
|
>
|
||||||
Les mots de passe ne correspondent pas.
|
Les mots de passe ne correspondent pas.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -65,7 +71,7 @@
|
|||||||
class="alert alert-success text-center"
|
class="alert alert-success text-center"
|
||||||
style="display: none"
|
style="display: none"
|
||||||
>
|
>
|
||||||
Votre mot de passe a été modifié avec succès !
|
Votre mot de passe a été modifié avec succès !
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary w-100" type="submit">
|
<button class="btn btn-primary w-100" type="submit">
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Mot de passe oublié</title>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
|
||||||
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background: #f2f4f7;
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.forgot-password-card {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 380px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="card shadow forgot-password-card">
|
|
||||||
<div class="card-body p-4">
|
|
||||||
<h3 class="text-center mb-4">Mot de passe oublié</h3>
|
|
||||||
|
|
||||||
<form>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Adresse e-mail</label>
|
|
||||||
<input type="email" class="form-control" placeholder="exemple@mail.com">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="btn btn-primary w-100">Réinitialiser le mot de passe</button>
|
|
||||||
|
|
||||||
<div class="text-center mt-3">
|
|
||||||
<a href="page_de_connexion.html" class="text-decoration-none">Retour à la connexion</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
const form= document.getElementById('resetForm');
|
|
||||||
const password = document.getElementById('password');
|
|
||||||
const confirmPassword = document.getElementById('confirmPassword');
|
|
||||||
const errorMsg = document.getElementById('errorMsg');
|
|
||||||
const successMsg = document.getElementById('successMsg');
|
|
||||||
|
|
||||||
form.addEventListener('submit', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (password.value !== confirmPassword.value) {
|
|
||||||
errorMsg.style.display = 'block';
|
|
||||||
successMsg.style.display = 'none';
|
|
||||||
} else {
|
|
||||||
errorMsg.style.display = 'none';
|
|
||||||
successMsg.style.display = 'block';
|
|
||||||
console.log('SUCCES');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user