我收到了一個我想了解的錯誤:SQLSTATE [42S22]:列未找到:1054'where子句'中的未知列'username'(SQL:select * from users
where ID電子郵件密碼名admin created_at的updated_at 1 [email protected] $ 2Y $ 10 $ 1R/21A3C32nwkjtEgDFcyuMc2D4AtgeFnTh1ygLEcQl ...去:試圖登錄Laravel身份驗證系統 - 表格不匹配
我的 '用戶' 表時username
= [email protected]限制1) 1 2014-11-01 21:04:33 2014-11-01 21:04:33 2 [email protected] $ 2y $ 10 $ Akb9BoLWrOcQT0KFee7vvujtrzkbeRQnUDcuCXepeAd ... hi 0 2014-11-02 16:15:47 2014年4月1日 - 11-02 16:15:47
我的意見(正確顯示)形式
@extends('login_c')
@section('loginform')
<?= '<span style="color:red">' .
Session::get('login_error') . '</span>' ?>
{{ Form::open() }}
{{ Form::label('email', 'Email address: ') }}
{{ Form::text('email', Input::old('email')) }}
<br>
{{ Form::label('password', 'Password: ') }}
{{ Form::password('password') }}
<br>
{{ Form::submit('Login!') }}
{{ Form::close() }}
@stop
的問題是,我之前指定我的密碼註冊,我不明白爲什麼我要麼得到「無法登錄」或SQL注入錯誤。
oute::get('registration', function()
{
return View::make('registration');
});
Route::post('registration', array('before' => 'csrf',
function()
{
$rules = array(
'email' => 'required|email|unique:users',
'password' => 'required|same:password_confirm',
'name' => 'required'
);
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails())
{
return Redirect::to('registration')->withErrors
($validation)->withInput();
}
$user = new User;
$user->email = Input::get('email');
$user->password = Hash::make(Input::get('password'));
$user->name = Input::get('name');
$user->admin = Input::get('admin') ? 1 : 0;
if ($user->save())
{
Auth::loginUsingId($user->id);
return Redirect::to('profile');
}
return Redirect::to('registration')->withInput();
}));
Route::get('profile', function()
{
if (Auth::check())
{
return 'Welcome! You have been authorized!';
}
else
{
return 'Please <a href="login">Login</a>';
}
});
Route::get('login', function()
{
return View::make('login');
});
Route::post('login', function()
{
$user = array(
'name' => Input::get('email'),
'password' => Input::get('password')
);
if (Auth::attempt($user))
{
return Redirect::to('profile');
}
return Redirect::to('login')->with('login_error',
'Could not log in.');
});
Route::get('secured', array('before' => 'auth', function()
{
return 'This is a secured page!';
}));
我的登記表。(對不起,我沒有張貼我的衆目睽睽之下,因爲它是不相關的,我敢肯定,誤差在形式和/或的usermodel
{{ Form::open() }}
{{ Form::label('email', 'Email address: ') }}
{{ Form::text('email', Input::old('email')) }}
<br>
{{ Form::label('password', 'Password: ') }}
{{ Form::password('password') }}
<br>
{{ Form::label('password_confirm',
'Retype Password: ') }}
{{ Form::password('password_confirm') }}
<br>
{{ Form::label('name', 'Name: ') }}
{{ Form::text('name', Input::old('name')) }}
<br>
{{ Form::label('admin', 'Admin?: ') }}
{{ Form::checkbox('admin','true',
Input::old('admin')) }}
<br>
{{ Form::submit('Register!') }}
{{ Form::close() }}
@stop
我應該如何改變我的用戶模型?爲什麼它保存了錯誤的密碼?
謝謝。一個問題:如果我打開數據庫,爲什麼會顯示錯誤的密碼?這是一個安全功能嗎? – Thankyou 2014-11-02 17:36:59
@StephanieNess不客氣。你是什麼意思* ...如果我打開數據庫顯示錯誤的密碼... *? – peterm 2014-11-03 00:37:45