gpt4 book ai didi

php - Laravel 5 中 RouteCollection.php 中的 MethodNotAllowedHttpException

转载 作者:行者123 更新时间:2023-12-02 05:17:12 26 4
gpt4 key购买 nike

routes.php

Route::get('/',array('uses'=>'student@index'));
Route::get('/view',array('uses'=>'student@view'));
Route::post('/save',array('uses'=>'student@save'));

这是代码,我正在处理表单,当我提交表单时,它显示了这个错误:

MethodNotAllowedHttpException in RouteCollection.php line 201:

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>

我被困在这里了。

最佳答案

那么,您需要在 httpd.conf 中配置允许的 HTTP 方法如果您在 Apache 服务器上。

将此行添加到您的 httpd.conf <Directory XXXX>标签:

AllowMethods GET POST OPTIONS

关于php - Laravel 5 中 RouteCollection.php 中的 MethodNotAllowedHttpException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31214247/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com