【问题标题】:Adding articles don't works PHP添加文章不起作用 PHP
【发布时间】:2013-07-16 12:12:49
【问题描述】:
<?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' );
        }
    }
    ?>

【问题讨论】:

  • 你遇到了什么错误?
  • 在不知道错误的情况下无法帮助。
  • 没有错误不要提交表单我现在不知道为什么




  • 我建议您先var_dump $_POST 变量,看看您的表单是否正在提交,然后分别进行数据库插入和重定向。

标签: php add article


【解决方案1】:

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

也许这解决了问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 2014-02-06
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    • 2013-02-17
    • 1970-01-01
    相关资源
    最近更新 更多