一直試圖創建一個遵循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