添加文章不适用于PHP

时间:2013-07-16 12:12:50

标签: php add article

<?php

session_start ();

include_once ('../include/connection.php');

if (isset ( $_SESSION ['logged_in'] )) {

    if (isset ( $_POST ['title'], $_POST ['content'] )) {
        $title = $_POST ['title'];
        $content = $_POST ['content'];

        if (empty ( $title ) or empty ( $content )) {
            $error = 'All fields are required';
        } else {

            $query = $pdo->prepare ( 'INSERT INTO articles (article_title, article_content, article_timestamp) VALUES (?, ?, ?)' );

            $query->bindValue ( 1, $title );
            $query->bindValue ( 2, $content );
            $query->bindValue ( 3, time () );

            $query->execute ();

            header ( 'Location: index.php' );
        }
    }
    ?>

1 个答案:

答案 0 :(得分:0)

请检查您的语法 - “}”缺失

也许这解决了问题