I am writing code, to delete a user from the database when they click the delete button. When the user clicks the button, they run the function "myFunction" which then makes an ajax call to the delete.php page. It should alert when the user is deleted. When I click the button, nothing happens and the user isn't deleted from the database.
This is the script:
<script>
function myFunction(){
$.ajax({
type:'POST',
url: 'delete.php',
success: function()
{
alert('deleted')
}
})
}
This is delete.php:
<?php
require_once(__DIR__.'/../includes/db.php');
session_start();
$theuser = $_SESSION['user_data']['user_id'];
if($_POST){
$stmt = $Conn->prepare ("DELETE * FROM users WHERE user_id =".$theuser);
$stmt->execute();
}
?>