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 10: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. }
本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏举报微信扫一扫
点击复制链接分享
编辑预览轻敲空格完成输入- 显示为
- 卡片
- 标题
- 链接
评论按下Enter换行,Ctrl+Enter发表内容
编辑
预览

轻敲空格完成输入
- 显示为
- 卡片
- 标题
- 链接
报告相同问题?
提交
- 2016-12-06 12:02回答 2 已采纳 You'd just add another element to your $data array. So your controller would look something like
- 2018-06-03 00:39回答 1 已采纳 With $this->upload->data('file_name'), you are getting only the last uploaded file name. You
- 2014-01-14 01:42回答 2 已采纳 To extend controller please either follow this tutorial or see some code below. differences bet
- 2020-08-26 01:28culi3182的博客 codeigniterPHPFog is a cloud hosting solution for PHP applications. It offers a free shared cloud that includes access to a MySQL database, and the ability to add 3 apps to your account. The main idea...
- 2019-05-03 05:59回答 1 已采纳 Http error 500 stands for a server error. You have a syntax error here require __DIR__ . 'librar
- 2017-09-06 00:19回答 1 已采纳 Try this class Blog extends CI_Contrller{ function create_blog() { // Check Login if (!
- 2018-05-20 10:53回答 1 已采纳 Sounds like you just need: urldecode() Decodes any %## encoding in the given string. Plus sym
- 2020-08-27 04:03culh2177的博客 在这个由两部分组成的系列文章中,我将讨论Fuel CMS的一些概念。 在这一部分中,我将讨论其安装以及如何设置视图。 在第二部分中,我将讨论编写Fuel CMS模块。 Fuel CMS快速概述 (A Quick Overview of Fuel CMS) ...
- 2019-07-24 04:19回答 1 已采纳 I think you should modify the .htaccess file to also include the subfolder : RewriteEngine on R
- 2016-10-11 02:06回答 1 已采纳 you can reduce the code a little but in controller like this: $this->data['users'] = $users; /
- 2016-02-04 22:49回答 2 已采纳 We can do it very simply in codeigniter version 3.0 eg, $this ->db ->select('*');
- 2017-08-09 10:41weixin_34102807的博客 1.1 PHP中判断变量的相关函数 1.2 strlen( )与mb_strlen( )的作用分别是什么(新浪网技术部) strlen 和mb_strlen 都是用于获取字符串长度的,其中strlen只针对单字节编码字符,也就是说它计算的是字符串的总字节...
- 2018-03-24 03:56钟长森的博客 双端队列中的元素可以从两端弹出,其限定插入和删除操作在表的两端进行。双向队列(双端队列)就像是一 个队列,但是你可以在任何一端添加或移除元素。而双端队列是一种数据结构,定义如下: A deque is a data ...
- 2018-09-05 10:33php小学一年级生的博客 该篇文章是针对Github上wudi/PHP-Interview-Best-Practices-in-China资源的答案个人整理 lz也是初学者,以下知识点均为自己整理且保持不断更新,也希望各路大神多多指点,若发现错误或有补充,可直接comment,lz...
- 2009-08-06 10:01happyxjg的博客 PHP新手面试题集第一份:PHP新手面试题总100分简述题(50分)1、用PHP打印出前一天的时间格式是2006-5-10 22:21:21(2分)echo date(Y-m-d H:i:s, strtotime(-1 day));2、echo(),print(),print_r()的区别(3分)echo是PHP...
- 2019-07-31 01:53weixin_30420305的博客 A——AJAX AJAX是异步JavaScript和XML的意思,它是近些年你使用的所有流畅的Web应用背后的主要驱动力。... 说到底它的核心是XMLHttpRequest,这允许在页面完全渲染之后发送请求并接收返回,而无...
- 2017-07-15 06:40猫猫猫猫猫大人的博客 1. windows消息机制(消息如何产生、如何发送、如何处理,常见的消息有哪些、消息的优先级、如何自定义消息、窗体消息、常用控件消息) 2. gdi原理(要熟悉gdi的各种对象,如画笔、画刷、字体、区域、裁剪、位图等...
- 2011-03-11 15:04白一梓的博客 第二天当你第二天见到Claudia时,她看上去十分期待。你问她出了什么问题,她也正好从问题说起。 “是这样,对于这个网站,我考虑了好久,发现我们遗漏了很重要的一点。...可不可以给搜索页加个超链接,或者在
- 2024-07-19 03:29绝不原创的飞龙的博客 在本书结束时,我们的最终交付物将是一个由 Symfony 框架构建的模块化网络商店应用程序。自 PHP 诞生以来已经过去了二十多年。最初由 Rasmus Lerdorf 于 1994 年创建,PHP 首字母缩略词最初代表。
- 2024-08-03 03:59绝不原创的飞龙的博客 在这一章中,我们介绍了 Composer 和 Packagist,以及如何一起使用它们来管理应用的依赖关系。我们从头到尾介绍了立即使用 Composer 所需的一切,以及在管理应用的依赖关系时使用 Composer 的各种日常交互。我们还...
- 没有解决我的问题, 去提问
联系我们(工作时间:8:30-22:00)
400-660-0108kefu@csdn.net在线客服
- 京ICP备19004658号
- 经营性网站备案信息
公安备案号11010502030143
- 营业执照
- 北京互联网违法和不良信息举报中心
- 家长监护
- 中国互联网举报中心
- 网络110报警服务
- Chrome商店下载
- 账号管理规范
- 版权与免责声明
- 版权申诉
- 出版物许可证
- ©1999-2025北京创新乐知网络技术有限公司