Laravel登录获取NULL参数

时间:2013-09-02 18:58:44

标签: php login parameters null laravel

我正在尝试laravel和php,我的登录有问题:

我有观点:

      {{ Form::open('login', 'POST') , ['class' => 'navbar-form navbar-right'] }}

            <div class="form-group">

                {{ Form::text('username', Input::old('username'), ['class' => 'form-control']) }}
            </div>
            <div class="form-group">

             {{  Form::password('password', ['class' => 'form-control'])        }}

            </div>

            {{ Form::submit('Login', ['class' => 'btn btn-primary']) }}
            <a class="btn btn-success" href="../registrarse">registrarse</a>
{{ Form::close() }}

和路线:

Route::post('/login', function(){
 $userdata = array(
        'username' => Input::get('username'),
        'password' => Input::get('password')
    );

    /* Try to authenticate the credentials */
    if(Auth::attempt($userdata)) 
    {
        // we are now logged in, go to admin
        return "oola";
    }
    else
    {
        return $userdata;
        return Redirect::to('registrarse');
    }});

我总是得到:

{"username":null,"password":null}

有什么问题?

1 个答案:

答案 0 :(得分:0)

Form::open()的语法不正确。请检查以下内容:

http://laravel.com/docs/html#opening-a-form

基本上你应该做点像

{{ Form::open(array('url' => 'login')) }}

该方法是可选的,默认为POST。