SHARE
TWEET

autre.php

a guest Feb 27th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $servername = "127.0.0.1";
  3. $dbname = "neridaar";
  4. $username = "ID";
  5. $password = "MDP";
  6.  
  7.     $bdd = new PDO("mysql:host=$servername;port=3306;dbname=$dbname; charset=utf8", $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
  8.     if(isset($_POST['article_titre'], $_POST['article_contenu'])) {
  9.         if(!empty($_POST['article_titre']) AND !empty($_POST['article_contenu'])){
  10.  
  11.             $article_titre = htmlspecialchars($_POST['article_titre']);
  12.             $article_contenu = htmlspecialchars($_POST['article_contenu']);
  13.  
  14.             $ins = $bdd->prepare('INSERT INTO articles (titre, contenu, date_time_publication)
  15.                 VALUES (?,?, NOW())');
  16.             $ins->execute(array($article_titre, $article_contenu));
  17.  
  18.             $message = "Votre article à bien été posté.";
  19.  
  20.  
  21.         } else {
  22.             $message = "Veuillez remplir tous les champs";
  23.         }
  24.     }
  25. ?>
  26.  
  27.  
  28. <!DOCTYPE html>
  29. <html lang="fr">
  30. <head>
  31.     <meta charset="UTF-8">
  32.     <title>Site Neridaar</title>
  33.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  34.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  35.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  36.     <link rel="stylesheet" href="../css/styles.css">
  37. </head>
  38. <body>
  39.     <nav class="navbar navbar-expand-md bg-dark navbar-dark sticky-top">
  40.       <a class="navbar-brand" href="#">Neridaar</a>
  41.       <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb" aria-expanded="true">
  42.         <span class="navbar-toggler-icon"></span>
  43.       </button>
  44.       <div id="navb" class="navbar-collapse collapse hide">
  45.         <ul class="navbar-nav">
  46.           <li class="nav-item">
  47.             <a class="nav-link" href="../html/index.php">Accueil</a>
  48.           </li>
  49.           <li class="nav-item active">
  50.             <a class="nav-link" href="../html/autre.php">Autre</a>
  51.           </li>
  52.           <li class="nav-item">
  53.             <a class="nav-link" href="../html/article.php">Article</a>
  54.           </li>
  55.         </ul>
  56.  
  57.         <ul class="nav navbar-nav ml-auto">
  58.           <li class="nav-item">
  59.             <a class="nav-link" href="../html/connexion.php"><span class="fas fa-sign-in-alt"></span> Login</a>
  60.           </li>
  61.         </ul>
  62.       </div>
  63.     </nav>
  64.  
  65.  
  66.  
  67.  
  68.  
  69. <form action="" method="POST">
  70.     <input class="champs" type="text" name="article_titre" placeholder="Titre"><br>
  71.     <textarea name="article_contenu" class="textArticle" placeholder="Rediger un article..."></textarea><br><br>
  72.     <input type="submit" class="btn_sub" name="submit" value="Poster">
  73. </form>
  74.  
  75. <?php
  76.     if(isset($message)) {
  77.         echo $message;
  78.     }
  79. ?>
  80.  
  81. </body>
  82. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top