用户正在登录,他想删除自己的状态。
<p><?php echo $status; ?></p> //this shows status
<a href="" id="<?php echo $upid; ?>" class="delete">Delete</a>
以下是下面的javascript ajax代码
<script type="text/javascript" >
$(function() {
$(".delete").click(function(){
var del_id = element.attr("id");
var info = 'id=' + del_id;
if(confirm("Sure you want to delete this update? There is NO undo!"))
{
$.ajax({
type: "POST",
url: "delete.php",
data: info,
success: function(){
}
});
$(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
.animate({ opacity: "hide" }, "slow");
}
return false;
});
});
</script>
这是我的代理人.php
<?php
include("includes/db_connect.php");
if(isset($_GET['id'])){
$delete_id = $_GET['id'];
$delete_query = "delete from user_posts where upid='$delete_id'";
mysqli_query($con, $delete_query);
}
?>
用户配置文件链接是profile.php?id=1这个id是用户id。不是帖子id。当我把鼠标移到删除按钮时,它在底部显示配置文件id,而不是删除id。帮我。
http://prntscr.com/3n517j
更改为,
if(isset($_POST['id'])){
$delete_id = $_POST['id'];
type: "POST",
将其更改为"GET"。
否则,您将无法在$_GET中找到值。