添加文章don';t工作于PHP

添加文章don';t工作于PHP,php,add,article,Php,Add,Article,请检查语法-“}”缺失 也许这就解决了问题您遇到的错误是什么?如果不知道错误就无能为力。没有错误不要提交表单我现在不知道为什么我建议您首先var\u转储$\u POST变量以查看表单是否正在提交,然后分别执行DB插入和重定向。 <?php session_start (); include_once ('../include/connection.php'); if (isset ( $_SESSION ['logged_in'] )) { if (isset ( $_PO

请检查语法-“}”缺失


也许这就解决了问题

您遇到的错误是什么?如果不知道错误就无能为力。没有错误不要提交表单我现在不知道为什么




我建议您首先var\u转储$\u POST变量以查看表单是否正在提交,然后分别执行DB插入和重定向。
<?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' );
        }
    }
    ?>