0

I am having an issue with working with post data.

For example, if i have a simple little form :

<form action='/leads/getpost' method='POST'>
<input type='text' name='Domain'>
<input type='submit' name='submit'>

AND then collect the data and try echo it out :

public function getPost()
    {
        $formData = Request::all() ;
        var_dump($formData);

        //
    }

I get an error : MethodNotAllowedHttpException in RouteCollection.php line 218:

If i do the same thing using GET it works fine.

I tried to edit the VerifyCsrfToken and added :

protected $except = [ 'leads/getpost'
        //
    ];

Still not working.

Matt
  • 3
  • 2
  • http://stackoverflow.com/questions/32718870/how-to-get-all-input-of-post-in-laravel-5 – Leszek P Feb 16 '17 at 17:27
  • @LeszekRepie , i tried those examples , still not working – Matt Feb 16 '17 at 17:30
  • https://laracasts.com/discuss/channels/laravel/methodnotallowedhttpexception-in-routecollectionphp-line-218 ? – Leszek P Feb 16 '17 at 17:31
  • 1
    The URL you're `POST`ing to isn't configured in your `routes.php` file. You need `Route::post("url", "Controller@getPost");` or something similar – Tim Lewis Feb 16 '17 at 18:06

1 Answers1

0

Try This

Route:

Route::post('leads/getpost', 'nameofController@getPost');

Controller:

use Request;

public function getPost()
    {
        $formData = Request::all();
        var_dump($formData); // or you could return it to the view

    }
MatHatrik
  • 762
  • 1
  • 6
  • 16