0

我正在尝试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}

怎么了?

4

1 回答 1

0

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

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

基本上你应该做类似的事情

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

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

于 2013-09-02T19:04:19.233 回答