Adamhumbug Posted November 14, 2020 Share Posted November 14, 2020 I have a user form with a dete button on a dropdown. When you click said button this runs function deleteUser(){ var e = event.target var uid = e.getAttribute("data-id"); console.log(e) console.log(uid) $.ajax({ type: 'post', data: {"ajax" : 'delUser', "id" : uid} }) } which goes into this if(isset($_POST['ajax'])){ switch($_POST['ajax']) { case 'newUserMod': exit(popNewUserModal()); break; case 'userMod': exit(popUserModal($_POST['id'])); break; case 'deleteUser': exit(deleteUser($_POST['id'])); break; } }; which calls this function in another file function deleteUser($id){ include 'includes/dbconn.php'; $stmt = $conn -> prepare("DELETE FROM user WHERE id = ?"); $stmt -> bind_param('i', $id); $stmt -> execute(); header('Location: manage-users'); } I know that i am getting the correct id in the ajax and i can see that the post happens correctly. Any ideas why the users are not being deleted? Quote Link to comment https://forums.phpfreaks.com/topic/311710-calling-functions-in-other-files/ Share on other sites More sharing options...
Solution Barand Posted November 14, 2020 Solution Share Posted November 14, 2020 Perhaps it's something to do with... Quote Link to comment https://forums.phpfreaks.com/topic/311710-calling-functions-in-other-files/#findComment-1582394 Share on other sites More sharing options...
Adamhumbug Posted November 14, 2020 Author Share Posted November 14, 2020 Yep that might do it. Cant see the woods for the trees! Thanks as always Quote Link to comment https://forums.phpfreaks.com/topic/311710-calling-functions-in-other-files/#findComment-1582397 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.