e.herrera e.herrera - 1 year ago 51
PHP Question

How can I get TokenMismatchException when trying to submit the form?

How can I place a token in laravel, I am getting a token error? Thank you for your collaboration.

enter image description here

Answer Source

I'm guessing the reason way Jeffery's code works is because the version of Laravel doesn't have default csrf protection, so if u want to make your form works, you have to manually add :

<input type="hidden" name="_token" value="{{ csrf_token() }}">

or create the form with the form helper:

{{ Form::open(array('url' => 'foo/bar')) }}
{{ Form::close() }}

which will automatically generate the hidden input tag of csrf token