Feedback Formulaire
This commit is contained in:
@ -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 */;
|
Reference in New Issue
Block a user