【发布时间】: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 变量,看看您的表单是否正在提交,然后分别进行数据库插入和重定向。