Advertisement
Guest User

Untitled

a guest
May 26th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="fr">
  3.  
  4. <head>
  5. </head>
  6.  
  7. <body>
  8.     <?php
  9.     try {
  10.         // On se connecte à MySQL
  11.         $bdd = new PDO('mysql:host=localhost;dbname=Geekzone;charset=utf8', 'root', 'root');
  12.     } catch (Exception $e) {
  13.         // En cas d'erreur, on affiche un message et on arrête tout
  14.         die('Erreur : ' . $e->getMessage());
  15.     }
  16.     ?>
  17.     <?php
  18.     //Reception des données
  19.     $nomProd = $_POST['nom'];
  20.     $descProd = $_POST['descProduit'];
  21.     $detailProd = $_POST['detail'];
  22.     $prixProd = $_POST['prix'];
  23.     $imgProd = $_POST['image'];
  24.     $categorieProd = $_POST['categorie'];
  25.     $insert = $bdd->prepare("INSERT INTO produit (nom,descProduit,detail,prix,image,categorie) VALUES(?,?,?,?,?,?)");
  26.     $insert->execute(array($nomProd, $descProd, $detailProd, $prixProd, $imgProd, $categorieProd));
  27.     header('Location: /geekzone/admin/products/add/');
  28.     ?>
  29.     <div class="TitreProd">
  30.         Ajout de produits
  31.     </div>
  32.     <br />
  33.     <form method="post">
  34.         <fieldset>
  35.             <legend> Nouveau produit</legend>
  36.             Nom produit: <input type="text" size="10" maxlength="40" name="nom" /><br /> <br />
  37.             Description du produit: <textarea type="text" size="50" maxlength="150" name="descProduit"></textarea><br />
  38.             Detail du produit : <textarea type="text" size="50" name="detail"></textarea><br />
  39.             <label>Prix du produit</label>
  40.             <input type="text" name="prix">
  41.             <label>Image du produit</label>
  42.             <input type="file" class="custom-file-input" id="image" name="image" required>
  43.             <label class="custom-file-label" for="image"></label>
  44.             <label>Categorie :</label> <br />
  45.             <select id="categorie" name="categorie">
  46.                 <option>1</option>
  47.                 <option>2</option>
  48.                 <option>3</option>
  49.                 <option>4</option>
  50.                 <option>5</option>
  51.             </select><br />
  52.             <br />
  53.             <input type="submit" name="envoyer" value="valider" />
  54.         </fieldset>
  55.     </form>
  56. </body>
  57.  
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement