User is login and he want to delete his status.
<p><?php echo $status; ?></p> //this shows status
<a href="" id="<?php echo $upid; ?>" class="delete">Delete</a>
here is javascript ajax code below
<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>
and this is my delete.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);
}
?>
User profile link is profile.php?id=1 This id is user ID.. not post ID.. when i move my mouse to delete button, at the bottom it shows profile id, not delete id. help me out.
type: "POST",
change this to "GET".
Otherwise you won't find the value in $_GET.
Change to,
if(isset($_POST['id'])){
$delete_id = $_POST['id'];
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.