[英]Laravel 4 login doesnt work
If i try to login i just get this url: 如果我尝试登录,我只会得到以下网址:
http://xx.xx.xx.xx/game/public/?_token=4kXP1sYlLIizUUMyMWluK6jSEOacDikXafUSVrIF&username=dieter&password=azerty http://xx.xx.xx.xx/game/public/?_token = 4kXP1sYlLIizUUMyMWluK6jSEOacDikXafUSVrIF&username = dieter&password = azerty
Im probably doing something stupid.. Here is my code: 我可能在做一些愚蠢的事情。这是我的代码:
controller: 控制器:
public function postSignin() {
if (Auth::attempt(array('username'=>Input::get('username'), 'password'=>Input::get('password')))) {
return Redirect::to('users/dashboard')
->with('message', 'You are logged in');
} else {
return Redirect::to('index')
->with('message', 'Your username/password combination was incorrent.')
->withInput();
}
}
Login form: 登录表单:
{{Form::open(array('url'=>'users/signin')) }}
{{ Form::text('username', null, array('class' => 'input-block-level', 'placeholder' => 'Username')) }}
{{ Form::password('password', null, array('class' => 'input-block-level', 'placeholder' => 'Password')) }}
{{ Form::submit('Login', array('class' => 'btn btn-default')) }}
{{ Form::close() }}
Routes: 路线:
<?php
Route::controller('users', 'UsersController');
Route::controller('/', 'HomeController');
It's like it is ignoring the 'url' in the login form. 就像忽略登录表单中的“ url”一样。 If i change it to something else it just responds the same way. 如果我将其更改为其他内容,它将以相同的方式响应。
I've bene googling all day for this, so please help. 我整天都在搜寻,所以请帮忙。 ^^ ^^
Thanks 谢谢
You've got a form without action
attribute, and your submit button sends you to the same page. 您有一个没有action
属性的表单,并且您的“提交”按钮会将您发送到同一页面。 Try to change the Form declaration as this: 尝试按以下方式更改Form声明:
{{ Form::open(array('route' => 'users/signin') ) }}
I hope this works fine. 我希望它能正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.