我对此有意见。我正在学习拉拉维尔,我正在制作一份表格。我的简单场景是这样的。当用户完成他/她的注册表格后,他们需要点击提交按钮。然后,如果有一个验证,它应该显示,表单不应该保存。如果没有错误,它应该保存。然后重定向到主页。我的错误是,在将数据保存在数据库中之后,我无法将页面重定向到索引。它将显示一个错误403禁止页面。
下面是我路线上的代码:
Route::model('employee','Employee');
Route::get('/','EmployeesController@index');
Route::get('/register', 'EmployeesController@register');
Route::get('/handleRegister', 'EmployeesController@handleRegister');
Route::post('/handleRegister', function()
{
$rules = array(
'emp_code' => 'numeric',
'lastname' => 'required|min:2|max:15',
'firstname' => 'required|min:2|max:20',
'middlename' => 'min:2|max:20',
'password' => 'required|min:8|max:30',
'cpassword' => 'required|same:password'
);
$validator = Validator::make(Input::all(), $rules);
if($validator->fails()) {
$messages = $validator->messages();
return Redirect::to('register')
->withErrors($messages)
->withInput(Input::except('password','cpassword'));
} else {
$employee = neW Employee;
$employee->emp_code = Input::get('emp_code');
$employee->lastname = Input::get('lastname');
$employee->firstname = Input::get('firstname');
$employee->middlename = Input::get('middlename');
$employee->gender = Input::get('gender');
$employee->birthday = Input::get('birthday');
$employee->password = Hash::make(Input::get('password'));
$employee->save();
return Redirect::action('EmployeesController@index');
}
}
);这是我的索引函数:
public function index()
{
return View::make('index', array(
'page_title' => 'Flax: Food Ordering',
'login_footer' => 'Flax Inc. @ '. date('Y'),
'register_link' => action('EmployeesController@register')
));
}然后,在我的浏览器中,我看到了以下内容:
Forbidden
You don't have permission to access /http://dev.flax_order.local on this server.
Apache/2.4.9 (Win64) OpenSSL/1.0.1g PHP/5.5.12 Server at dev.flax_order.local Port 80在URL中,我注意到以下内容:
http://dev.flax_order.local/http://dev.flax_order.local它使链接加倍。
我不知道我的错误在哪里。你能帮我做这个吗?
顺便说一句,这是跑步的路线
php artisan routes
C:\wamp\vhosts\flax_order>php artisan routes
+--------+---------------------+------+------------------------------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+--------+---------------------+------+------------------------------+----------------+---------------+
| | GET|HEAD / | | EmployeesController@index | | |
| | GET|HEAD register | | EmployeesController@register | | |
| | POST handleRegister | | Closure | | |
+--------+---------------------+------+------------------------------+----------------+---------------+发布于 2014-10-28 07:02:45
试着改变
return Redirect::action('EmployeesController@index');转入:
return Redirect::to('/');虽然我在这里没有看到错误,但是主机名中的下划线可能会导致这个问题。
https://stackoverflow.com/questions/26602334
复制相似问题