SHARE
TWEET

Untitled

a guest Jun 20th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']). '?post=' . $index->actualPrefix(); ?>" method="post" id="comentarios">
  2.             <textarea name="comments" id="comments"></textarea>
  3.             <input type="submit" value="Comment">
  4. <?php if (!empty($errores)): ?>
  5.             <div class="error">
  6.                     <ul>
  7.                         <?php echo $errores; ?>
  8.                     </ul>
  9.             </div>
  10. <?php endif; ?>
  11.         </form>
  12.      
  13. if($_SERVER['REQUEST_METHOD'] == 'POST'){
  14.     $article = $index->actualPrefix();
  15.     $user = $index->limpiarDatos($_SESSION["id_user"]);
  16.     $comment = $index->limpiarDatos($_POST['comments']);
  17.     if (empty($comment)) {
  18.         $errores .= '<li>An empty comment was sent, rejected</li>';
  19.     }
  20.     if ($errores == '') {
  21.         $conexion = new Conexion();
  22.         $statement = $conexion->prepare(
  23.             'INSERT INTO comment (id_article, id_user, content) VALUES (:id_article, :id_user, :content)'
  24.         );
  25.         $statement->execute(array(
  26.             ':id_article' => $article,
  27.             ':id_user' => $user,
  28.             ':content' => $comment
  29.         ));
  30.     }
  31. }
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