Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']). '?post=' . $index->actualPrefix(); ?>" method="post" id="comentarios">
- <textarea name="comments" id="comments"></textarea>
- <input type="submit" value="Comment">
- <?php if (!empty($errores)): ?>
- <div class="error">
- <ul>
- <?php echo $errores; ?>
- </ul>
- </div>
- <?php endif; ?>
- </form>
- if($_SERVER['REQUEST_METHOD'] == 'POST'){
- $article = $index->actualPrefix();
- $user = $index->limpiarDatos($_SESSION["id_user"]);
- $comment = $index->limpiarDatos($_POST['comments']);
- if (empty($comment)) {
- $errores .= '<li>An empty comment was sent, rejected</li>';
- }
- if ($errores == '') {
- $conexion = new Conexion();
- $statement = $conexion->prepare(
- 'INSERT INTO comment (id_article, id_user, content) VALUES (:id_article, :id_user, :content)'
- );
- $statement->execute(array(
- ':id_article' => $article,
- ':id_user' => $user,
- ':content' => $comment
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement