Delete page

There is a simple script. There, through the GET parameter, the id of the record and the name of the table are passed, and this record is deleted, and then sent back through the Header. There was a need to add confirmation of deletion. I can’t figure out how. It turns out that you need to save the incoming get… show the page with the confirmation form and then delete the record when submitting and go back.

Answer 1, authority 100%

Do you need a deletion confirmation page? Just the question will come down through js? 🙂
Well then here’s an option:
according to your description, there is a link, clicking on which deletes a record in the table, and then returns to the page with the link, for example, <a href="/admin/action.php?act=del&amp;id=5&amp;backurl=/admin/index.php"> </a>.
Now let’s try to delete the confirmation record.
Let’s create a js file and put the following code in it

function confirmdel(id, backurl) {
    var answer = confirm("     № "+id+"?");
    if (answer){
        window.location = "/admin/action.php?act=del&amp;id="+id+"&amp;backurl="+backurl;

and replace the link that was in the example with

<a href="#" onclick="confirmdel('5','/admin/index.php')"> </a>

Now, when you click on the link, you will first be asked Are you sure you want to delete record number 5?And depending on your decision, either the record will be deleted or nothing will happen.

Answer 2, authority 33%

In the original form, add a hidden field with the name delete and the value confirm

if(isset($_GET['id']) && isset($_GET['delete'])){
    //  ,   delete   'ok'   
    // ,  

Answer 3, authority 33%

    //    action = $_SERVER['REQUEST_URI'].'&delete'

And I don’t trust js – it may not load, glitch, or even be disabled.

Answer 4

Well, yes, that’s right, or when clicking through JS, call a modal confirmation window.

Answer 5

Better with Javascript, before sending the deletion request, use the global confirm method –