Jump to content

Calling functions in other files


Adamhumbug
Go to solution Solved by Barand,

Recommended Posts

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.