Form post does not work in Laravel 4

0

I'm trying to send data from a form via the POST method, but it's not going to work at all.

Follow my code

// routes.php
Route::any('/', function()
{
    echo Request::getMethod();   // Aqui esta sempre retornando GET
    return View::make( '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>

Regardless of whether the screen was loaded by the link or the submit button, the return from Request :: getMethod () is always being GET, so it does not have any data in $ _POST, why does this happen?     

asked by anonymous 17.10.2014 / 04:18

2 answers

1

Request :: getMethod () returns the http (verb) method used in the request. Strange to be returning GET if you put post in your html form.

To retrieve parameters sent in the request, you must use other commands:

Request::all() // retorna um array com todos os parâmetros
    
01.11.2014 / 12:42
0

You came to give f12 and see if the post is actually being sent, I think so. What's wrong with your code is

Request::getMethod();
Think of me ... If the method of your form is post, why do you think that gettingMethod () will return something besides get?

I particularly use Input :: all (), but I've already seen codes using Request :: all ();

That's when you decide what's best for you

    
23.10.2014 / 19:52