1

I'm creating a form inside of a bootstrap modal. Here is the form:

<form action="{{ url('/post')}}" method="POST" id="my_form">
  {{ csrf_field() }}
  <input type="text" name="Comments" id="Comments">
  <button onclick="form_submit()">Submit</button>
</form>

and here is the javascript I'm using to post it:

<script type="text/javascript">
function form_submit() {
  document.getElementById("my_form").submit();
 }
</script>

Unfortunately, when I submit, I get the following error:

(1/1) TokenMismatchException in VerifyCsrfToken.php (line 68)

I've also tried to insert a hidden field for the token:

<input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />

Unfortunately, no luck.

Any idea how I can fix this?

Thanks!

1 Answer 1

1

Insert this somewhere in ur header

 <meta name="c-token" content="{!! csrf_token() !!}" />
Sign up to request clarification or add additional context in comments.

1 Comment

Incredible! Thanks @vdeshan!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.