Laravel 5.6 recover data from a form?

0

Error

  Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

     

No message

No Controller Method

class GuzzleController extends Controller
{
    public function post(Request $request){
    $email = $request->input('email');
    $senha = $request->input('senha');

    dd($email,$senha);
}

web.php

Route::get('/post', 'GuzzleController@post');

index.php

Note: here I get lost

<body>
    <form action="/post" method="POST">
         E-mail: <input type="text" name="email"><br>   
         senha: <input type="text" name="senha"><br>
         <input type="submit">
    </form>
</body>
    
asked by anonymous 12.03.2018 / 23:44

1 answer

2

On routes change accordingly

Route::any('/post', 'GuzzleController@post')->name('postForm');

The% w / w will take all the methods and how you want only POST can put

Route::post

Another good thing is to put a name on your routes, so you can change the URL dynamically without having to change it in multiple files.

Do not forget the CSRF token , it is required in Laravel, in POST

<form method="POST" action="{{route('postForm')}}">
@csrf
  E-mail: <input type="text" name="email"><br>   
     senha: <input type="text" name="senha"><br>
     <input type="submit">
</form>

Try to put the view name as Route::any

    
13.03.2018 / 02:41