/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018-4-3
* Time: 15:23
*/
namespace app\index\controller;
use app\common\controller\Base;
use app\common\model\Test as TestModel;
class Test extends Base
{
public function test1()
{
return $this->fetch();
}
public function insert()
{
if (Request::isAjax()){
$data = Request::except('password_confirm','post');
if(TestModel::create($data)){
return ['status'=>1 , 'message'=>'恭喜,注册成功!'];
}else{
return ['status'=>0 , 'message'=>'注册失败!'];
}
}
else{
$this->error("请求类型错误",'register');
}
}
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
最上面添加use think\Request
另外 insert()这个方法里面需要传入参数,insert(Requset $request)
{
$data = $request->param();
}