Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="fr">
- <head>
- </head>
- <body>
- <?php
- try {
- // On se connecte à MySQL
- $bdd = new PDO('mysql:host=localhost;dbname=Geekzone;charset=utf8', 'root', 'root');
- } catch (Exception $e) {
- // En cas d'erreur, on affiche un message et on arrête tout
- die('Erreur : ' . $e->getMessage());
- }
- ?>
- <?php
- //Reception des données
- $nomProd = $_POST['nom'];
- $descProd = $_POST['descProduit'];
- $detailProd = $_POST['detail'];
- $prixProd = $_POST['prix'];
- $imgProd = $_POST['image'];
- $categorieProd = $_POST['categorie'];
- $insert = $bdd->prepare("INSERT INTO produit (nom,descProduit,detail,prix,image,categorie) VALUES(?,?,?,?,?,?)");
- $insert->execute(array($nomProd, $descProd, $detailProd, $prixProd, $imgProd, $categorieProd));
- header('Location: /geekzone/admin/products/add/');
- ?>
- <div class="TitreProd">
- Ajout de produits
- </div>
- <br />
- <form method="post">
- <fieldset>
- <legend> Nouveau produit</legend>
- Nom produit: <input type="text" size="10" maxlength="40" name="nom" /><br /> <br />
- Description du produit: <textarea type="text" size="50" maxlength="150" name="descProduit"></textarea><br />
- Detail du produit : <textarea type="text" size="50" name="detail"></textarea><br />
- <label>Prix du produit</label>
- <input type="text" name="prix">
- <label>Image du produit</label>
- <input type="file" class="custom-file-input" id="image" name="image" required>
- <label class="custom-file-label" for="image"></label>
- <label>Categorie :</label> <br />
- <select id="categorie" name="categorie">
- <option>1</option>
- <option>2</option>
- <option>3</option>
- <option>4</option>
- <option>5</option>
- </select><br />
- <br />
- <input type="submit" name="envoyer" value="valider" />
- </fieldset>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement