Feedback Formulaire
This commit is contained in:
parent
b43367cdcd
commit
ae2c0ad184
@ -104,6 +104,15 @@ pre code {
|
||||
max-width: 200px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.error {
|
||||
color: #ff7f7f !important;
|
||||
}
|
||||
.success {
|
||||
color: #90EE90 !important;
|
||||
}
|
||||
.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* FOOTER */
|
||||
footer
|
||||
|
@ -60,8 +60,8 @@
|
||||
<li class="nav-item <?php echo $functionlistActive?>">
|
||||
<a class="nav-link" href="/views/function-list.php">Liste des fonctions</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" target="_blank" href="https://docs.google.com/forms/d/1NliUWi3lntHDM42Td0C47J0cZKgnYilxT_0UcdmVaog/">Feedback Formulaire</a>
|
||||
<li class="nav-item <?php echo $feedbackActive?>">
|
||||
<a class="nav-link" href="/views/feedback-form_view.php">Feedback Formulaire</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" target="_blank" href="https://github.com/Divlo/FunctionProject">Code Source</a>
|
||||
|
@ -22,9 +22,9 @@
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6 pb-4">
|
||||
<div class="text-center pb-5">
|
||||
<h2 class="function-list-title"><a target="_blank" href="https://docs.google.com/forms/d/1NliUWi3lntHDM42Td0C47J0cZKgnYilxT_0UcdmVaog/">Donnez votre avis :</a></h2>
|
||||
<a target="_blank" href="https://docs.google.com/forms/d/1NliUWi3lntHDM42Td0C47J0cZKgnYilxT_0UcdmVaog/"><img class="function-list-image" src="/img/Feedback-Formulaire.png" alt=""></a>
|
||||
<p class="function-list-description">Vous pouvez m'envoyer votre avis sur le projet grâce au <a href="https://docs.google.com/forms/d/1NliUWi3lntHDM42Td0C47J0cZKgnYilxT_0UcdmVaog/" target="_blank">Feedback Formulaire</a> 📝.</p>
|
||||
<h2 class="function-list-title"><a href="/views/feedback-form_view.php">Donnez votre avis :</a></h2>
|
||||
<a href="/views/feedback-form_view.php"><img class="function-list-image" src="/img/Feedback-Formulaire.png" alt=""></a>
|
||||
<p class="function-list-description">Vous pouvez m'envoyer votre avis sur le projet grâce au <a href="/views/feedback-form_view.php">Feedback Formulaire</a> 📝.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -4,6 +4,7 @@ $currentpage = $_SERVER['PHP_SELF'];
|
||||
|
||||
$indexActive = '';
|
||||
$functionlistActive = '';
|
||||
$feedbackActive = '';
|
||||
|
||||
switch ($currentpage) {
|
||||
case '/index.php':
|
||||
@ -18,6 +19,17 @@ switch ($currentpage) {
|
||||
$image = 'https://function.divlo.fr/img/FunctionProject_icon.png';
|
||||
$functionlistActive = 'active';
|
||||
break;
|
||||
case '/views/feedback-form_view.php':
|
||||
$title = 'Feedback Formulaire';
|
||||
$description = "Vous pouvez m'envoyer votre avis sur le projet grâce à ce formulaire 📝.";
|
||||
$image = 'https://function.divlo.fr/img/Feedback-Formulaire.png';
|
||||
$feedbackActive = 'active';
|
||||
break;
|
||||
case '/views/feedback-list.php':
|
||||
$title = 'Liste des feedback';
|
||||
$description = "La liste de tous les feedbacks publiés.";
|
||||
$image = 'https://function.divlo.fr/img/Feedback-Formulaire.png';
|
||||
break;
|
||||
case '/views/function-views/calculateAge.php':
|
||||
$title = 'Quel âge avez-vous ?';
|
||||
$description = "Calcule l'âge selon la date de naissance.";
|
||||
|
33
php/feedbackForm.php
Normal file
33
php/feedbackForm.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// Connexion à la base de donnée
|
||||
require_once('./config_database/connectDB.php');
|
||||
|
||||
/**
|
||||
* Permet de sécuriser une chaine de caractères
|
||||
* @param $string
|
||||
* @return string
|
||||
*/
|
||||
function str_secur($string) {
|
||||
return trim(htmlspecialchars($string));
|
||||
}
|
||||
|
||||
$array = array("feedback" => "", "message" => "", "isSuccess" => false);
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
$array["feedback"] = str_secur($_POST["feedback"]);
|
||||
$array["pseudo"] = str_secur($_POST["pseudo"]);
|
||||
|
||||
if(empty($array['feedback']) || empty($array['pseudo'])) {
|
||||
$array["message"] = "<p class='error'><b class='error'>Erreur:</b> <span class='italic'>Vous ne pouvez pas rentré de valeur vide.</span></p>";
|
||||
} else {
|
||||
$req = $bdd->prepare("INSERT INTO functiondivlofr_feedback(pseudo, feedback) VALUES (?,?)");
|
||||
$req->execute(array($array['pseudo'], $array['feedback']));
|
||||
|
||||
$array["message"] = "<p class='success'><b class='success'>Succès:</b> Votre feedback a été envoyé!</p>";
|
||||
$array["isSuccess"] = true;
|
||||
}
|
||||
|
||||
echo json_encode($array);
|
||||
}
|
34
php/functiondivlofr_feedback.sql
Normal file
34
php/functiondivlofr_feedback.sql
Normal file
@ -0,0 +1,34 @@
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
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 */;
|
||||
|
||||
--
|
||||
-- Base de données : `divlofrjzbroot`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `functiondivlofr_feedback`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `functiondivlofr_feedback`;
|
||||
CREATE TABLE IF NOT EXISTS `functiondivlofr_feedback` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`pseudo` text NOT NULL,
|
||||
`feedback` text NOT NULL,
|
||||
`statut` varchar(255) NOT NULL DEFAULT 'En cours de validation',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
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 */;
|
@ -219,4 +219,22 @@ $(function () {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#feedbackForm').submit((e) => {
|
||||
e.preventDefault();
|
||||
const postdata = $('#feedbackForm').serialize();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../../php/feedbackForm.php',
|
||||
data: postdata,
|
||||
success: (response) => {
|
||||
const result = JSON.parse(response);
|
||||
$(".results").html(result.message);
|
||||
if(result.isSuccess) {
|
||||
$("#feedbackForm")[0].reset();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
34
views/feedback-form_view.php
Normal file
34
views/feedback-form_view.php
Normal file
@ -0,0 +1,34 @@
|
||||
<!-- Config -->
|
||||
<?php include("../php/config.php");?>
|
||||
|
||||
<!-- Header -->
|
||||
<?php include("../incl/header.php");?>
|
||||
|
||||
<!-- Page Content -->
|
||||
<div class="container">
|
||||
<h1><span class="important"><?php echo $title?></span> :</h1>
|
||||
<p class="pt-3 text-center"><?php echo $description?> <br>
|
||||
Note : Tous les feedbacks publiés sont publics. <br>
|
||||
<a href="/views/feedback-list.php">La liste des feedbacks publiés</a>
|
||||
</p>
|
||||
<form id="feedbackForm" method="POST">
|
||||
<div class="form-group">
|
||||
<label for="pseudo">Entrez votre pseudo :</label>
|
||||
<input name="pseudo" type="text" id="pseudo" placeholder="Divlo" class="form-control">
|
||||
<br>
|
||||
<label for="feedback">Votre message :</label>
|
||||
<textarea name="feedback" type="text" id="feedback" placeholder="Soyez le plus précis possible dans votre ressenti afin que je puisse améliorer au mieux le projet. ⚙️" class="form-control"></textarea>
|
||||
<br>
|
||||
<div class="form-row text-center">
|
||||
<div class="col-12">
|
||||
<button type="submit" id="submitFeedback" class="btn btn-dark text-center">Envoyer</button>
|
||||
</div>
|
||||
</div>
|
||||
<br> <br>
|
||||
<p class="results text-center"></p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<?php include("../incl/footer.php");?>
|
42
views/feedback-list.php
Normal file
42
views/feedback-list.php
Normal file
@ -0,0 +1,42 @@
|
||||
<!-- Config -->
|
||||
<?php include("../php/config.php");?>
|
||||
|
||||
<!-- Header -->
|
||||
<?php include("../incl/header.php");?>
|
||||
|
||||
<!-- Page Content -->
|
||||
<div class="container">
|
||||
<h1><span class="important"><?php echo $title?></span> :</h1>
|
||||
<p class="pt-3 text-center">
|
||||
<?php echo $description?> <br>
|
||||
<a href="/views/feedback-form_view.php">Revenir au formulaire</a>
|
||||
</p>
|
||||
|
||||
<table class="table table-bordered mt-5">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center" scope="col">Pseudo</th>
|
||||
<th class="text-center" scope="col">Feedback</th>
|
||||
<th class="text-center" scope="col">Statut</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
<?php
|
||||
$path = $_SERVER['DOCUMENT_ROOT'];
|
||||
// Connexion à la base de donnée
|
||||
require_once($path.'/php/config_database/connectDB.php');
|
||||
|
||||
$req = $bdd->query("SELECT * FROM functiondivlofr_feedback");
|
||||
|
||||
while($row = $req->fetch()) { ?>
|
||||
<tr>
|
||||
<td class="important"><?= $row['pseudo'] ?></td>
|
||||
<td><?= $row['feedback'] ?></td>
|
||||
<td><?= $row['statut'] ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Footer -->
|
||||
<?php include("../incl/footer.php");?>
|
Reference in New Issue
Block a user