routes.php文件
Route::get('/',array('uses'=>'student@index'));
Route::get('/view',array('uses'=>'student@view'));
Route::post('/save',array('uses'=>'student@save'));
这是代码,我正在处理表单,当我提交表单时,它会显示以下错误:
RouteCollection.php第201行中的MethodNotAllowedHttpException:
student.php
class student extends Controller {
public function index()
{
//return 'hello world';
return \View::make('student.index');
}
public function view()
{
return \View::make('student.view');
}
public function save()
{
//return \View::make('student.view');
$validation= array(
'first_name'=>'required',
'email'=>'required'
);
$v1=validator::make(Input::all(),$validation);
if( $v1->fails())
{
return Redirect::to('view')->withErrors($v1);
}
else
{ $poststudent=Input::all();
$data = array('first_name'=>$poststudent['first_name'],
'last_name'=>$poststudent['last_name'],
'email'=>$poststudent['email'],
'interested'=>$poststudent['interested'],
'skills'=>$poststudent['skills']);
$check=0;
$check=DB::table('students')->insert($data);
if($check > 0)
{
return Redirect::to('/');
}
else
{
return Redirect::to('/view');
}
}
}
}
表格是这样的:
<form action="<?=URL::to('/save')?>" methed="POST">
<div class="form-group">
<label for= "first_name"> FIRST NAME </label>
<input name="FIRST NAME" type="text" value="" class="form-control" id="first name"/>
</div>
我被困在这里。
答案 0 :(得分:0)
好吧,如果您在Apache服务器上,则需要在httpd.conf
中配置允许的HTTP方法。
将此行添加到httpd.conf
<Directory XXXX>
代码中
AllowMethods GET POST OPTIONS
答案 1 :(得分:-1)
<form>
...标记之后。或者您将获得TokenMissmatch例外。