我正在使用Laravel创建我的登录页面
我希望使用POST方法发送我的登录表单数据,但是无法正常工作
// /view/login.blade.php
/*
{{ Form::open([
"route" => "user/login",
"autocomplete" => "off",
'method' => 'POST'
]) }}
{{ Form::label("username", "Usuário:") }}
{{ Form::text("username", Input::old("username"), [
"placeholder" => "john.smith"
]) }}
{{ Form::label("password", "Senha:") }}
{{ Form::password("password", [
"placeholder" => "*******"
]) }}
{{ Form::submit("Entrar") }}
{{ Form::close() }}
//---------------------------------------
// routes.php
Route::any( '/', [
"as" => "user/login",
"uses" => "UserController@loginAction"
] );
//---------------------------------------
// /controllers/UserController.php
class UserController extends Controller
{
public function loginAction()
{
echo Input::server( "REQUEST_METHOD" ); // This line is ever print "GET"
return View::make( 'user/login' );
}
}*/
[代码编辑]
// view/login.blade.php
<form action="{{URL::to('/')}}" method="post">
<input name="login" type="text"/><br/>
<input type="password" name="senha" id=""/><br/>
{{ Form::submit('Enviar') }}
</form>
// routes.php
Route::any('/', function()
{
echo Request::getMethod(); is returning GET forever
return View::make( 'login' );
});
显然,我的表单将使用POST方法发送数据,但我永远无法在$ _POST中获取数据,为什么?
答案 0 :(得分:0)
您应该使用:
Input::all()
获取所有数据
或Input::get('username')
,Input::get('password')
等等,以获取所选数据。