【发布时间】:2013-12-27 17:42:42
【问题描述】:
我正在用 laravel 编写一个简单的身份验证表单。
在尝试了两个不同的教程后,它仍然返回 false。
注册工作正常,但我的登录不是。
这是登录控制器:
public function getLogin() {
$this->layout->content = View::make('user.login');
}
public function postSignin() {
if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password'))))
{
return Redirect::to('user/dashboard')->with('message', 'You are now logged in!');
}
else
{
return Redirect::to('user/login')
->with('message', 'Your username/password combination was incorrect')
->withInput();
}
}
public function getDashboard() {
$this->layout->content = View::make('user.dashboard');
}
路线:
Route::controller('user', 'UserController');
和视图:
{{ Form::open(array('url'=>'user/signin', 'class'=>'form-signin')) }}
<h2 class="form-signin-heading">Please Login</h2>
{{ Form::text('username', null, array('class'=>'input-block-level', 'placeholder'=>'Username')) }}
{{ Form::password('password', array('class'=>'input-block-level', 'placeholder'=>'Password')) }}
{{ Form::submit('Login', array('class'=>'btn btn-large btn-primary btn-block'))}}
{{ Form::close() }}
【问题讨论】:
标签: php mysql authentication laravel