我尝试Auth::attempt
这是我的控制器
public function LoginCP()
{
$uname = Input::get('uname');
$pass = Input::get('pass');
$input = array(
'User Name'=> $uname,
'password' => $pass
);
$rules = array(
'User Name' => 'required',
'password' => 'required');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::to('login')->withErrors($validator);
}
$userdata = array(
'uname' => Input::get('uname'),
'pass' => Input::get('pass')
);
if (Auth::attempt($userdata)) {
// validation successful!
echo 'SUCCESS!';
} else {
return 'Errorrr';
我的刀片文件
@extends('master')
@section('main')
{{-- this is the Form post to login --}}
<center>
<h1>Here is the login form</h1>
{{ Form::open(array('url' => 'login')) }}
{{ Form::label('uname', 'User Name : '); }}
{{ Form::text('uname'); }}
<br>
{{ Form::label('pass', 'Password : ');}}
{{ Form::Password('pass')}}
<br>
{{ Form::submit('submit')}}
<br>
{{ $errors}}
{{ Form::close(); }}
</center>
@endsection
我的数据库表是用户 和行 ID UNAME 名称 通
我的路线档案
Route::get('/', function()
{
return View::make('hello');
});
Route::get('reg', 'HomeController@showReg');
Route::post('reg', 'HomeController@addUser');
Route::get('login', 'HomeController@showLogin');
Route::post('login', 'HomeController@loginCP');
Route::get('sucess', function()
{
return View::make('sucess');
});
我的用户模型
<?php
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
public $timestamps = false;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('pass');
/**
* Get the unique identifier for the user.
*
* @return mixed
*/
public function getAuthIdentifier()
{
return $this->getKey();
}
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword()
{
return $this->pass;
}
/**
* Get the token value for the "remember me" session.
*
* @return string
*/
public function getRememberToken()
{
return $this->remember_token;
}
/**
* Set the token value for the "remember me" session.
*
* @param string $value
* @return void
*/
public function setRememberToken($value)
{
$this->remember_token = $value;
}
/**
* Get the column name for the "remember me" token.
*
* @return string
*/
public function getRememberTokenName()
{
return 'remember_token';
}
/**
* Get the e-mail address where password reminders are sent.
*
* @return string
*/
public function getReminderEmail()
{
return $this->email;
}
}
最后我的Auth文件
<?php
return array(
'driver' => 'eloquent',
'model' => 'User',
'table' => 'users',
'reminder' => array(
'email' => 'emails.auth.reminder',
'table' => 'password_reminders',
'expire' => 60,
),
);
我不知道我的代码中的错误部分在哪里
请帮助我,我想了解如何做到这一点