i have one button in my form which supposed to insert the data into database and send the data as an email. so my question is can i separate the function in controller? i already tried to put both (insert into database and sending the data as an email) in only one function. it really looked messed up since the function i actually wanted to do is more than those 2.
public function insertdata(){...}
and public function sendemail(){...}
maybe something like that.
make 1按钮在控制器php codeigniter中执行两个不同的功能
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- doutao5499 2017-06-21 18:14关注
Yes of course, this is possible. You create two functions using the first function insert data and check your data will be inserted or not. If inserted then call the second function and send your mail. For example:
public function insertdata(){ $data = $this->input->post(); //add model $result = $this->insert_model->InsertData($data); if($result>0){ $this->sendmail($data); }else{ $this->session->set_flashdata('Your data not inserted'); } } public function sendmail($data){ //here you can read data and write code for send email. }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 机器人轨迹规划相关问题
- ¥15 word样式右侧翻页键消失
- ¥15 springboot+vue 集成keycloak sso到阿里云
- ¥15 win7系统进入桌面过一秒后突然黑屏
- ¥30 backtrader对于期货交易的现金和资产计算的问题
- ¥15 求C# .net4.8小报表工具
- ¥15 安装虚拟机时出现问题
- ¥15 Selenium+docker Chrome不能运行
- ¥15 mac电脑,安装charles后无法正常抓包
- ¥18 visio打开文件一直显示文件未找到