PHP: Show yes/no confirmation dialog

后端 未结 13 2076
爱一瞬间的悲伤
爱一瞬间的悲伤 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:59

    I was also looking for a way to do it and figured it out like this using forms and the formaction attribute:

    
    Are you sure? 
    ';?>
    

    action.php would check for isset($_POST['del_confirm']) and call the corresponding php script (for database actions or whatever). Voilà, no javascript needed. Using the formaction attribute, the delete button can be part of any form and still call a different form action (such as refer back to the same page, but with the button set).

    If the button was pressed, the confirm buttons will show.

提交回复
热议问题