I have created this PHP script to update the status of users. I am having some difficulty while running the below code. The code of the page is given below: -
$query = "DELETE FROM users WHERE id='$id' ";
$query_run = mysqli_query($conn, $query);
if($query_run)
{
$_SESSION['status'] = "Successfully Deleted";
header('Location: index.php');
}
else
{
$_SESSION['status'] = "Something Went Wrong.!";
header('Location: index.php');
}
The query here fails to run. The below ajax code sends the data to this page using a POST request
$.ajax({
type: "POST",
url: "code.php",
data: {
'checking_edit_btn': true,
'student_id': stud_id,
},
success: function (response) {
$.each(response, function (key, value) {
$('#edit_id').val(value['id']);
});
$('#editStudentModal').modal('show');
};
});
update It's working now, here is the final code:
$.ajax({
type: "POST",
url: "code.php",
data: {
'delete_student': true,
'student_id': stud_id,
},
success: function (response) {
$.each(response, function (key, value) {
$('#edit_id').val(value['id']);
});
$('#editStudentModal').modal('show');
};
});
where you sending 'update_student'/'delete_student'?
try to add to data
update_student: true
or
delete_student: true
depends on button
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.