Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once ("./req/core.php");
- if(isset($_POST['submit'])){
- if(!empty($_POST['nom']) && !empty($_POST['prenom']) && !empty($_POST['email']) && !empty($_POST['avis']) && !empty($_POST['rate'])){
- // Convertit les caractères spéciaux en entités HTML
- $nom = htmlspecialchars($_POST['nom']);
- $prenom = htmlspecialchars($_POST['prenom']);
- $email = htmlspecialchars($_POST['email']);
- $avis = htmlspecialchars($_POST['avis']);
- $note = htmlspecialchars($_POST['rate']);
- try{
- $db->beginTransaction();
- $ajout = $db->prepare("INSERT INTO AVIS SET NOM = ?, PRENOM = ?, EMAIL = ?, COMMENTAIRE = ?, NOTE = ?");
- $ajout->execute(array($nom,$prenom, $email, $avis, $note));
- $db->commit();
- } catch (PDOException $exception) {
- $db->rollBack();
- $notification->addAlertMessage("<b>Error : </b>".$exception->getMessage()." (".$exception->getCode().")<br>Erreur lors d'une requete, veuillez réessayer ou contactez un administrateur.", 2);
- $notification->setAlert();
- }
- $notification->addAlertMessage("Votre avis à bien été pris en compte !", 0);
- $notification->setAlert();
- header('Location: ./avis.php');
- exit();
- }
- $notification->setAlert();
- }
- if(isset($_GET['id']) and is_numeric($_GET['id'])) {
- $id = intval($_GET['id']);
- echo "string";
- exit();
- try{
- $db->beginTransaction();
- $avis = $db->prepare('SELECT * FROM AVIS ORDER BY ID');
- $avis->execute();
- $allavis = $avis->fetchAll();
- $db->commit();
- } catch (PDOException $exception) {
- header('Location: ./avis.php');
- $db->rollBack();
- $notification->addAlertMessage("<b>Error : </b>".$exception->getMessage()." (".$exception->getCode().")<br>Erreur lors d'une requete, veuillez réessayer ou contactez un administrateur.", 2);
- $notification->setAlert();
- exit();
- }
- }
- var_dump($avis);
- ?>
- <?php include("./commons/header.php"); ?>
- <script src="../../js/wysibb.js"></script>
- <link rel="stylesheet" href="../css/avis.css">
- <body>
- <?php include("./commons/menu.php"); ?>
- <!-- Affichage du système d'alerte -->
- <?php $notification->showAlert(); ?>
- <!--Formulaire-->
- <div class="container mt-3">
- <h3>Laissez-nous votre avis</h3>
- <hr>
- <form method="POST" action="" enctype="multipart/form-data">
- <div class="form-row">
- <div class="form-group col-md-6">
- <label>Nom</label>
- <input type="text" class="form-control" name="nom" placeholder="Nom" >
- </div>
- <div class="form-group col-md-6">
- <label>Prénom</label>
- <input type="text" class="form-control" name="prenom" placeholder="Prénom" >
- </div>
- </div>
- <div class="form-group">
- <label>Email</label>
- <input type="email" class="form-control" name="email" placeholder="Email" >
- </div>
- <div class="form-group">
- <label>Avis</label>
- <input type="text" class="form-control" name="avis" placeholder="Avis" required>
- </select>
- </div>
- <div class="form-group">
- <label>Note</label>
- <div class="rate">
- <input type="radio" id="star5" name="rate" value="5" />
- <label for="star5" title="5">5 stars</label>
- <input type="radio" id="star4" name="rate" value="4" />
- <label for="star4" title="4">4 stars</label>
- <input type="radio" id="star3" name="rate" value="3" />
- <label for="star3" title="3">3 stars</label>
- <input type="radio" id="star2" name="rate" value="2" />
- <label for="star2" title="2">2 stars</label>
- <input type="radio" id="star1" name="rate" value="1" />
- <label for="star1" title="1">1 stars</label>
- </div>
- </div>
- <button type="submit" name="submit" class="btn btn-primary btn-block">Envoyer</button>
- </form>
- </div>
- <br>
- <br>
- <div class="container">
- <h3>Avis utilisateur</h3>
- <hr>
- <br>
- <?php foreach ($allavis as $row) { ?>
- <div class="incoming_msg">
- <div class="received_msg">
- <h5><?= $row->NOM ?></h5>
- <div class="received_withd_msg">
- <p><?= $row->COMMENTAIRE ?></p>
- <span class="time_date"></span>
- </div>
- </div>
- </div>
- <?php } ?>
- </div>
- <?php include("./commons/footer.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement