register.html文件
User文件函数
public function insert()
{
if(Request::isAjax()){
//使用模型创建数据
//获取用户通过表达提交过来的数据
$data = Request::except('password_confirm','post');
if(UserModel::create($data)){
return ['status' => 1,'message'=>'注册成功'];
}else{
return ['status' => 0,'message' =>'注册失败'];
}
}else{
$this->error("请求类型错误",'register');
}
}
请问老师为什么提交没有反应呢,数据库也没有成功添加
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
可以直接在User.php里面引用think/Db,用Db来insert数据
我的问题和你一样,我把ajax提交的路径{url('insert')}换成绝对路径就对了,不知道什么原因。
你好,我也是这个问题,请问下怎么解决?
你现在成功了吗 我也是这个问题
确定你引入jquery了
确定ajax 传递数据了
后台php接收数据
有数据库,表,字段与你添加的数据对应
只能帮你到这了