PHP: Show yes/no confirmation dialog

后端 未结 13 2113
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 18:27

My PHP page has a link to delete one MySQL table datum. I want it to be in such a way that when I click the \'delete\' link a confirmation box should appear and it should ask \

13条回答
  •  暖寄归人
    2021-01-30 18:56

    What I usually do is create a delete page that shows a confirmation form if the request method is "GET" and deletes the data if the method was "POST" and the user chose the "Yes" option.

    Then, in the page with the delete link, I add an onclick function (or just use the jQuery confirm plugin) that uses AJAX to post to the link, bypassing the confirmation page.

    Here's the idea in pseudo code:

    delete.php:

    
    
    
    Are you sure?

    Page with delete link:

    
    
    Delete record
    

提交回复
热议问题