无论出于何种原因,这都会在我的检查器/网络窗口中返回301 Permanently Moved错误。它也没有将表单数据发布到表中。
index.blade.php文件
{{ Form::open(array('url' => '/')) }}
{{ Form::text('firstname' , '', array('placeholder' => 'first name'))}}
{{ Form::text('lastname' , '', array('placeholder' => 'last name'))}}
{{ Form::submit('add name', array('class' => 'btn btn-success'))}}
{{ Form::close() }}
路线档案
<?php
Route::get('/', function(){
return View::make('index');
});
Route::post('/', function() {
$input = Input::all();
DB::insert('insert into Donkey (firstname, lastname) values (?, ?)', array($input['firstname'], $input['lastname']));
});
任何想法?
答案 0 :(得分:0)
你做错了,请改用:
$input = Input::all();
DB::table('Donkey')->insert(
array('firstname' => $input['firstname'], 'lastname' => $input['lastname'])
);