I'm quite new to CodeIgniter (using PHP). So right now I have a textbox on my webpage where visitors are requested to enter in their names. I take in a name (i'll use the variable $username for it) and I want to save it in a database I have. I am wondering how I can do that. Do I somehow pass $username to a function in the Controller and then pass that value to my Model? Thank you very much, a simple example would be much appreciated!!
2条回答 默认 最新
- dongou5100 2013-02-08 05:20关注
<form method="post" action="<?php echo base_url();?>controller/save" name="form"> <label>User Name</label> <input type="text" name="Username"> <input type="submit" value="Add"/> </form>
in controller
function save { $arrData["Username"] = $this->input->post("Username"); $this->User_model->Add($arrData); }
in User_model
function Add($arrData) { if($this->db->insert(tableName, $arrData)) return true; else return false; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
- ¥15 知识蒸馏实战博客问题
- ¥15 用PLC设计纸袋糊底机送料系统
- ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
- ¥15 用C语言输入方程怎么
- ¥15 网站显示不安全连接问题
- ¥15 51单片机显示器问题
- ¥20 关于#qt#的问题:Qt代码的移植问题
- ¥50 求图像处理的matlab方案
- ¥50 winform中使用edge的Kiosk模式