这是我用来创建登录和注册页面的程序
在验证部分中,我没有找到语法函数,也没有找到更改,您能帮我吗?
使用:intelephense
$validate = $this->validation->run($data, 'register');代码:
public function __construct()
{
helper(['form', 'url']);
$this->validation = \Config\Services::validation();
$this->session = session();
}
$data = $this->request->getPost();
$validate = $this->validtion->run($data, 'register');
$errors = $this->validation->getErrors();
// Data2
if (!$errors) {
$this->model = new UserModel();
$user = new \App\Entities\Users();
$user->username = $this->request->getPost('username');
$user->name = $this->request->getPost('name');
$user->name_instansi = $this->request->getPost('name_instansi');
$user->alamat_instansi = $this->request->getPost('alamat_instansi');
$user->email = $this->request->getPost('email');
$user->password = $this->request->getPost('password');
$user->repeatPassword = $this->request->getPost('repeatPassword');
$user->created_by = 0;
$user->created_date = date("Y-m-d H:i:s");
$user = $this->userModel->save($user);
return view('login');
}
$this->session->setFlashdata('errors', $errors);
}
return view('/Geolab/auth/register');
}发布于 2021-10-29 02:18:38
我不太明白你的问题。问题标题中错误的来源在错误消息中。您可以使用以下代码行创建$validate变量:
$validate = $this->validation->run($data, 'register');但是,您不能在其他任何地方使用$validate变量。你确定没有你想用的地方吗?也许下一行应该是$errors = $validate->getErrors()?我不能肯定,因为我不知道你的validation类是什么。但问题中的错误实际上是因为您没有在其他地方使用$validate;如果这是故意的,请不要创建变量并将行更改为:
$this->validation->run($data, 'register'); // don't save result to a variable you're not usinghttps://stackoverflow.com/questions/69762000
复制相似问题