|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php include('inc/core.php');
- if (!isLogged()) {
- header('Location: login.php');
- die('<a href="login.php">Cliquez ici si vous n\'êtes pas redirigé automatiquement');
- }
-
- if (isset($_POST['title']) && isset($_POST['status']) && isset($_POST['price']) && isset($_POST['shipping']) && isset($_POST['shippingOrigin']) && isset($_POST['description'])) {
-
-
- $pdoStat = $mysql->prepare('INSERT INTO products VALUES (NULL, :nom, :qualite, :prix, :prixlivr, :pays, :description, :iduser, :mail, NOW())');
- $pdoStat->bindValue(':nom', $_POST['title'], PDO::PARAM_STR);
- $pdoStat->bindValue(':qualite', $_POST['status'], PDO::PARAM_STR);
- $pdoStat->bindValue(':prix', $_POST['price'], PDO::PARAM_STR);
- $pdoStat->bindValue(':prixlivr', $_POST['shipping'], PDO::PARAM_STR);
- $pdoStat->bindValue(':pays', $_POST['shippingOrigin'], PDO::PARAM_STR);
- $pdoStat->bindValue(':description', $_POST['description'], PDO::PARAM_STR);
- $pdoStat->bindValue(':iduser', $_SESSION['id'], PDO::PARAM_STR);
- $pdoStat->bindValue(':mail', $_SESSION['login'], PDO::PARAM_STR);
-
- $insertIsOk = $pdoStat->execute();
-
- if ($insertIsOk) {
- $message = $_SESSION['message'] = 'Votre annonce a bien été publiée.';
- $message_type = $_SESSION['message_type'] = 'success';
- header('Location: my_sell.php');
- } else {
- $message = 'Votre demande n\'a pas pu aboutir. Veuillez réessayer plus tard.';
- $message_type = 'danger';
- }
- }
-
- include('inc/header.php');
- ?>
- <main role="main" class="container">
- <div class="d-flex align-items-center p-3 my-3 text-white-50 bg-purple rounded box-shadow">
- <div class="lh-100">
- <h6 class="mb-0 text-white lh-100">Mise en vente</h6>
- </div>
- </div>
-
- <?php if (isset($message)) {
- if (isset($_SESSION['message'])) {
- unset($_SESSION['message']);
- unset($_SESSION['message_type']);
- }
- ?>
- <div class="alert alert-<?= $message_type ?>" role="alert">
- <?= $message ?>
- </div>
- <?php } ?>
-
- <div class="my-3 p-3 bg-white rounded box-shadow">
- <form method="post">
- <div class="form-group">
- <label for="title">Titre de l'annonce</label>
- <input type="text" class="form-control" id="title" name="title"
- placeholder="Detroit: Become Human pour PS4" required>
- </div>
- <div class="form-group">
- <label for="status">Etat</label>
- <select class="form-control" id="status" name="status" required>
- <option>Neuf</option>
- <option>Occasion</option>
- </select>
- </div>
- <div class="form-group">
- <label for="price">Prix</label>
- <input type="number" class="form-control" id="price" name="price"
- placeholder="35" required>
- </div>
- <div class="form-group">
- <label for="shipping">Frais de port</label>
- <input type="number" class="form-control" id="shipping" name="shipping"
- placeholder="5" required>
- </div>
- <div class="form-group">
- <label for="shippingOrigin">Pays d'expedition</label>
- <input type="text" class="form-control" id="shippingOrigin" name="shippingOrigin"
- placeholder="France" required>
- </div>
- <div class="form-group">
- <label for="description">Description</label>
- <textarea class="form-control" id="description" name="description" rows="3"
- placeholder="Je met en vente mon jeu Detroit: Become Human sur PS4..., remise en main propre possible"
- required></textarea>
- </div>
- <button class="btn btn-primary btn-block" type="submit">Mettre en vente</button>
- </form>
- </div>
- </main>
-
- <?php include('inc/footer.php'); ?>
|