mercredi 30 septembre 2015

Getting TokenMismatchException in VerifyCsrfToken.php line 53 in CRUD made using appzcoder/crud-generator in laravel 5.1

I've tried many solutions I can found on the stackoverflow and laracast. But my problem is slightly different, I get this TokenMismatchException in VerifyCSrfToken.php exception, but once I refresh the page, this error is gone and I'm able to submit the form properly. This has been happening every time, I fill the form, I get the exception and when I refresh, the error is gone. I'm using LaravelCollective for form generation. I've tried clearing all 3 types of cache. I've also tried adding the line manually, but this doesn't do any good, it actually led to same line twice in code as HTML generator has added this line itself, I removed it, still nothing is working. Here's code of my create.blade.php file.

@extends('layouts.master')

@section('content')

<h1>Contact Us</h1>
<hr/>

{!! Form::open(['url' => 'contact', 'class' => 'form-horizontal']) !!}
<div class="form-group">
                    {!! Form::label('name', 'Name: ', ['class' => 'col-sm-3 control-label']) !!}
                    <div class="col-sm-6">
                        {!! Form::text('name', null, ['class' => 'form-control']) !!}
                    </div>
                </div><div class="form-group">
                    {!! Form::label('email', 'Email: ', ['class' => 'col-sm-3 control-label']) !!}
                    <div class="col-sm-6">
                        {!! Form::text('email', null, ['class' => 'form-control']) !!}
                    </div>
                </div><div class="form-group">
                    {!! Form::label('phone', 'Phone: ', ['class' => 'col-sm-3 control-label']) !!}
                    <div class="col-sm-6">
                        {!! Form::text('phone', null, ['class' => 'form-control']) !!}
                    </div>
                </div><div class="form-group">
                    {!! Form::label('message', 'Message: ', ['class' => 'col-sm-3 control-label']) !!}
                    <div class="col-sm-6">
                        {!! Form::textarea('message', null, ['class' => 'form-control']) !!}
                    </div>
                </div>

<div class="form-group">
    <div class="col-sm-offset-3 col-sm-3">
        {!! Form::submit('Submit', ['class' => 'btn btn-primary form-control']) !!}
    </div>    
</div>
{!! Form::close() !!}

@if ($errors->any())
    <ul class="alert alert-danger">
        @foreach ($errors->all() as $error)
            <li>{{ $error }}</li>
        @endforeach
    </ul>
@endif

@endsection



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire