I am using ISSET condition to add comment on the page after saving it to database.
if (ISSET($_POST['comment_submit'])) {
$comment_author = $_POST['comment_author'];
$comment_content = $_POST['comment_content'];
$post_id = $_POST['post_id'];
if ($comment_content!="") {
$new_comment = mysql_query("INSERT INTO comment (post_id, comment_author, comment_content, comment_date) VALUES ('$post_id', '$comment_author','$comment_content', now())");
}
}
but after redirecting to same page its not showing comment posted recently. On refersh it starts displaying.
将在数据库中插入数据的代码放在插入查询之后。
If you are redirecting the user to same page, you won't get values in $_POST variable, since the form is not submitted again. You may have to store comment_author and comment_content values in session or you may have to pass these values while refreshing the page.
it seems that you're using pure php only.
header("Location: url")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.