Well, I have two files, the first one(users.php) displays the users and put “delete” link next to each user.and the other file(delete.php) delete records when someone clicks on the “delete link”.
Here’s the delete.php :
$user_id = $_REQUEST['id'];
$delete_query = sprintf("DELETE FROM 'tablename' WHERE id = %d", $id);
mysql_query($delete_query);
$msg = "the users has been deleted";
header("Location: http://localhost/intranet/in-admin-panel/users.php?success_message={$msg}");
exit();
My problem is, when I made the pagination to paginate the users, I found myself redirected to the first page even when I delete a user in the page3 for exemple(which is obvious from the script)
I tried redirecting to the previous page using($_SERVER[‘HTTP_REFERER’]), but as I read it’s not secure and not practical.
I’m wondering if there is a solution to this issue using php,or I’m forced to learn ajax to do it.
that could easily be done with JQuery, check the simple example below:
and Bang!! you have your delete without refreshing the page.
in case you are not familiar, you will need to use JQuery framework to use the code above. access http://jquery.com/download/ to get the .js file