Dragos Strugar Dragos Strugar - 7 months ago 26
PHP Question

Executing Post request in Laravel gives TokenMismatchException

I have a

model with title and content attributes. I also have views that display all notes (index) and specific note (show). That works fine.
Now I was about to create a form and create Notes from the form, and there was an error:
TokenMismatchException in VerifyCsrfToken.php line 67:
Here is my Routes file:

Route::get('/notes', 'NotesController@index');
Route::get('notes/{note}', 'NotesController@show');

Route::post('/notes', 'NotesController@create');

My controller is on Gist.

And my view.

How can I get rid of this error, and what is causing it?

mmm mmm

Add a hidden input field

<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>

and have a look at laravel's documentation