[英]Update table column on different page
当用户单击X
按钮删除评论时,我试图将表中的列从 0 更新为 1。 当我尝试删除评论时,我得到 else 语句,说未设置。
comment_frame.php:
if ($userLoggedIn == $posted_by) {
echo $delete_button = "
<form action='includes/form_handlers/delete_comment.php?comment_id=$comment_idd'
method='GET' >
<button name='delete_com' class='delete_comment btn-danger'
>X " . $comment_id . "</button></form>";
}
delete_comment.php:
if(isset($_GET['comment_id'])) {
$comment_id = $_GET['comment_id'];
} else {
echo "Not set.";
}
当从浏览器发送 GET 表单时,查询字符串将由表单的输入组成。 编译后的查询字符串将替换action
属性中存在的任何查询字符串。
因此,当您提交表单时,查询字符串如下所示
?delete_com=
没有comment_id
。
要解决此问题,请发送 POST 请求或将comment_id
作为隐藏输入字段。
echo "<form action='includes/form_handlers/delete_comment.php' method='GET' >
<input type='hidden' name='comment_id' value='".htmlspecialchars($comment_idd, ENT_QUOTES)."' />
<button name='delete_com' class='delete_comment btn-danger'
>X ".htmlspecialchars($comment_id, ENT_QUOTES)."</button>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.