Advertisement
abbest

ajout_annonce.php

Mar 28th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.40 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <title>Bootstrap Example</title>
  5.   <meta charset="utf-8">
  6.   <meta name="viewport" content="width=device-width, initial-scale=1">
  7.   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  8.   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  9.   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  10. </head>
  11. <body>
  12.  
  13. <div class="container">
  14.   <h2>Ajout Annonce</h2>
  15.   <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  16.      <div class="form-group">
  17.       <label for="ville">Ville :</label>
  18.       <select class="form-control" name="ville">
  19.         <option value="Tunis">Tunis</option>
  20.         <option value="Ariana">Ariana</option>
  21.         <option value="Mannouba">Mannouba</option>
  22.         <option value="Bizerte">Bizerte</option>
  23.         <option value="Ben Arous">Ben Arous</option>
  24.       </select>
  25.       </div>
  26.       <br>
  27.       <div class="form-group">
  28.       <label for="ville">Catégorie :</label>
  29.       <label class="radio-inline">
  30.       <input type="radio" name="categorie" value="auto">Automobile
  31.     </label>
  32.     <label class="radio-inline">
  33.       <input type="radio" name="categorie" value="info">Informatique
  34.     </label>
  35.     <label class="radio-inline">
  36.       <input type="radio" name="categorie" value="divers">Divers
  37.     </label>
  38.     </div>
  39.     <div class="form-group">
  40.       <label for="pwd">Titre:</label>
  41.       <input type="text" class="form-control" name="titre" placeholder="Entrer titre">
  42.     </div>
  43.     <div class="form-group">
  44.       <label for="comment">Contenu :</label>
  45.       <textarea class="form-control" rows="5" name="contenu"></textarea>
  46.     </div>
  47.    
  48.     <button type="submit" class="btn btn-default" name="btn_ajouter">Ajouter</button>
  49.   </form>
  50. </div>
  51. <?php
  52. if(isset($_POST['btn_ajouter'])):
  53.     include_once('../lib/annonce.class.php');
  54.     $annonce=new annonce();
  55.  
  56.     extract($_POST);
  57.     $annonce->ville=$ville;
  58.     $annonce->categorie=$categorie;
  59.     $annonce->titre=$titre;
  60.     $annonce->contenu=$contenu;
  61.     if($annonce->saveAnnonce()) echo 'Vous avez cliqué sur le bouton Ajouter';
  62.     else echo 'Nope';
  63. endif;
  64. if(isset($_POST['btn_ajouter'])):
  65.     include_once('../lib/annonce.class.php');
  66.     $annonce=new annonce();
  67.     $donnees=$annonce->getAnnonce();
  68.     include_once('affiche_annonce.phtml');
  69. endif;
  70. ?>
  71.  
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement