This article mainly introduces the simple implementation method of the pop-up confirmation box before thinkPHP is deleted, and analyzes the effect of the front-end HTML section of thinkPHP combined with the js control pop-up box and the deletion data processing function of the back-end controller in combination with the example, if you want to delete thinkPHP, you can refer to the following example to describe the simple implementation method of the pop-up confirmation box before thinkPHP is deleted. We will share this with you for your reference. The details are as follows:
Html section:
The Code is as follows:
Delete
Javascript section:
Script function del () {if (confirm ("are you sure you want to delete it? ") {Return true;} else {return false;} script
Controller part:
Public function shanchu () {$ id = $ this-> _ request ('id'); if ($ id) {$ user = M ('user '); $ data ['id'] = $ id; $ rs = $ user-> where ($ data)-> delete (); if ($ rs) {$ this-> success ('deleted successfully! ');} Else {$ this-> error ('deletion failed! ') ;}} Else {$ this-> error ('deletion failed! ');}}
Supplement: The editor recommends a php formatting and formatting typographical tool on this site to help you typeset code in future PHP programming:
Php code online formatting and beautification tools:Http://tools.php.net/code/phpformat