一直试图创建一个遵循laracast视频的用户注册/登录页面。使用laravel将注册数据存储在数据库中5.4
但是,当我尝试注册一个用户时,它返回到同一页面,而没有给出任何错误,为什么。我还注意到提供的信息没有存储在数据库中。
感到很困惑,我不知道我是什么,你的帮助将非常感激
这里做错了,是我的看法:
<div class="col-md-offset-1 col-md-8">
<h1 class="text-center ">Register</h1>
<form method="POST" action="register" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" email="email" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" name="password" required>
</div>
<div class="form-group">
<label for="password_confirmation">Password Confirmation</label>
<input type="password" class="form-control" name="password_confirmation" required>
</div>
<button type="submit" class="btn btn-primary"><i class="fa fa-reply"></i>Register</button>
</form>
</div>
这是我的控制器
public function create()
{
return view('registration.create');
}
public function store(Request $request)
{
//validate form
$this->validate(request(),[
'name' => 'required',
'email' => 'required|email',
'password' => 'required|confirmed',
]);
//create and save user
$user = new User; //create new Post model object
$user->name = $request->name; //adding thing to the the Post object
$user->email = $request->email;
$user->password = $request->password;
//save user
$user->save(); //to save the new item into the DB
//$user = User::create(request(['name', 'email', 'password']));
//sign them in
auth()->login($user);
//redirect to the admin
return redirect('/admin');
}
虽然这是我的路线文件:
Route::get('register', '[email protected]');
Route::post('register', '[email protected]');
非常感谢
可能是未通过验证规则。这个地方最有可能''密码'=>'需要|确认','你能否尝试检查你的验证是否失败? 'if($ validate-> failed())//显示错误' – Michel