Laravel 5.2 提交表单数据

Laravel 5.2 Submitting Form Data

我正在向 /add route 提交表单,但是当我点击提交按钮时出现了这个错误 使用:幼虫 5

{ SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '$name' for key 'name' (SQL: insert into projects (id, name, money, anything) values (, $name, 20, asfsf)) }

表格:

{!! Form::open(array('url' => 'add')) !!}
  {!! Form::text('name', 'example@gmail.com') !!}
  {!! Form::submit('Click Me!')!}
{!! Form::close() !!}

Routes.php

Route::post('add', function () {
   $test = Input::get('name');
   echo $test;
});

数据库快照:

PS: 我想回显输入字段值,但出现上述错误。

您没有为 ID 插入任何内容。注意 values (, $name, 20, asfsf)) }.

中逗号前的空白 space

如果您的 id 字段设置为自动递增(看起来是这样),那么请从您的插入语句中删除 id

insert into projects (name, money, anything) values ($name, 20, 'asfsf')