我正试图用幼虫5刷新自己,因为我一年没有接触过幼虫,并且在提交表格时我遇到了表格令牌的问题。
我通过本书并使用最佳实践做了所有事情(据我所知)。我遇到的问题是,当我提交表单时,我收到令牌不匹配错误。
VerifyCsrfToken.php第67行中的TokenMismatchException:
我环顾网络,从我所看到的,我正在做我应该做的一切。这是我的表格
@extends('app')
@section('content')
<div class="row">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Articles</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
</ul>
<ul class="nav nav-pills navbar-right">
<li role="presentation" class="active"><a href="{{ url('articles') }}">Back</a></li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</nav>
</div>
<div class="row">
{!! Form::open(['url' => 'articles']) !!}
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', '', ['class' => 'form-control']); !!}
</div>
<div class="form-group">
{!! Form::label('body', 'Body:') !!}
{!! Form::textarea('body', '', ['class' => 'form-control']); !!}
</div>
<div class="form-group">
{!! Form::label('published_at', 'Publish On:') !!}
<!--{!! Form::date('date', \Carbon\Carbon::now(), ['class' => 'form-control']); !!}-->
{!! Form::input('date', 'published_at', date('Y-m-d'), ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Add Article', ['class' => 'btn btn-primary form-control']); !!}
</div>
{!! Form::close() !!}
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
</div>
@endsection
以下是从浏览器中获取的源代码。
<form method="POST" action="http://laravel/articles" accept-charset="UTF-8">
<input name="_token" type="hidden" value="wygz8Wm8tMAdTDxE5fSXkyJIWUVxorOU5xu2R66s">
<div class="form-group">
<label for="title">Title:</label>
<input class="form-control" name="title" type="text" value="" id="title">
</div>
<div class="form-group">
<label for="body">Body:</label>
<textarea class="form-control" name="body" cols="50" rows="10" id="body"></textarea>
</div>
<div class="form-group">
<label for="published_at">Publish On:</label>
<!--<input class="form-control" name="date" type="date" value="2016-01-04">-->
<input class="form-control" name="published_at" type="date" value="2016-01-04" id="published_at">
</div>
<div class="form-group">
<input class="btn btn-primary form-control" type="submit" value="Add Article">
</div>
</form>
知道我哪里出错了?