0
有人可以解释我为什么我得到存储在标题和文章数据库中的空字段。我添加如果为空标题和文章,但看起来像东西不工作空字段仍然存储在数据库中..数据库中的空字段
我也试过if(isset($ _ POST ['submit'])& &!empty($ _ POST [“submit”]))但没有成功..
任何建议?
if(isset($_POST['submit'])) {
$date_added = date("Y-m-d H:i:s");
$author = $_POST['author'];
if(empty($_POST['title'])) {
echo "title is required";
} else {
$title = $_POST['title'];
}
if(empty($_POST['article'])) {
echo "article is required";
} else {
$article = $_POST['article'];
}
$query = mysqli_query($con, "INSERT INTO posts (date_added, title, article, author) VALUES ('$date_added', '$title', '$article', '$author')");
if(!$query) {
die("QUERY FAILED" . " " . mysqli_error($con));
}
}
谢谢..!