This article mainly introduces the function of sending text messages when goods are sold based on PHP. The code is simple and easy to understand. If you need it, you can refer to a project recently, where you need it, we are required to implement this function: send text messages when goods are sold. The core code below will be provided for you to learn later.
Html code omitted .....
Model Code omitted .....
The core code is as follows:
/** ----------------------------------------------- * Modify the public * Author: lzp Time: -- * required */public function changeStateAction () {$ id = $ _ REQUEST ['id']; $ result = $ this-> changeConfirmState ($ id); if ($ result) {$ this-> success ("modified successfully ");} else {$ this-> error ("failed to modify") ;}} private function changeConfirmState ($ id) {$ reg = $ this-> priceModel-> selectPrice (['id' => ['eq', $ Id]); $ rel = $ this-> demandModel-> selectDemand (['id' => ['eq ', $ reg [] ['demand _ id']); $ demand_id = $ reg [] ['demand _ id']; $ reg ['demand'] = $ this-> priceModel-> selectPrice (['demand _ id' => ['eq ', $ demand_id]); foreach ($ reg ['demand'] as $ key => $ value) {if ($ value ['phone'] = $ reg [] ['phone']) {unset ($ reg ['demand'] [$ key]);} else {$ new [] = $ value ['phone'] ;}} $ new = [''=> '*********']; if (time ()-strtotime ($ rel [] ['crea Te_time '])>) {echo "script alert ('timeout! '); History. back (); script "; die;} else if (strtotime ($ rel [] ['finish _ time'])>) {echo "script" alert ('closed! '); History. back (); script "; die;} else {$ data_demand = ['is _ available '=>, 'finish _ time' => date ("Y-m-d H: I: s")]; $ result ['price'] = $ this-> priceModel-> savePrice (['id' => ['eq ', $ id], ['state' =>]); $ result ['demon'] = $ this-> demandModel-> saveDemand (['id' => ['eq ', $ reg [] ['demand _ id'], $ data_demand); $ mobile = implode (",", $ new); $ content = "this requirement has been closed, come back next time! "; SmsApp ($ mobile, $ content); // send a text message return $ result ;}}
The above code is the core code provided by the editor. The code is still simple, so I didn't write too many comments for you. If you encounter any problems during the reference process, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the script home website!