문제가 있습니다. 나는 Laravel을 연구 중이며 양식을 작성 중입니다. 내 간단한 시나리오는 이렇습니다. 사용자가 등록 양식을 마친 후에는 제출 버튼을 클릭해야합니다. 그런 다음 유효성 검사가 표시되고 양식이 저장되지 않아야합니다. 오류가 없으면 저장해야합니다. 홈 페이지로 리디렉션합니다. 내 오류가 있습니다, 데이터베이스에 데이터를 저장 한 후 페이지를 인덱스로 리디렉션 할 수 없습니다. 403 금지 페이지 오류가 표시됩니다.Laravel을 사용하여 양식을 데이터베이스에 저장 한 후 페이지를 리디렉션하는 방법은 무엇입니까?
Route::model('employee','Employee');
Route::get('/','[email protected]');
Route::get('/register', '[email protected]');
Route::get('/handleRegister', '[email protected]');
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('[email protected]');
}
}
);
가 여기 내 인덱스 기능입니다 : 여기
내 경로에있는 코드의public function index()
{
return View::make('index', array(
'page_title' => 'Flax: Food Ordering',
'login_footer' => 'Flax Inc. @ '. date('Y'),
'register_link' => action('[email protected]')
));
}
그런 다음 브라우저에서 나는이있다 : 내가 눈치 URL에서
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
을 이 :
http://dev.flax_order.local/http://dev.flax_order.local
링크가 두 배가됩니다.
내 오류는 어디에서 확인할 수 있습니까? 이걸로 나를 도울 수 있니? 어쩌면 호스트 이름에 밑줄
return Redirect::to('/');
내가 여기에 오류가 표시되지 않지만 여기 그런데
는
return Redirect::action('[email protected]');
로 변경
php artisan routes
C:\wamp\vhosts\flax_order>php artisan routes
+--------+---------------------+------+------------------------------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+--------+---------------------+------+------------------------------+----------------+---------------+
| | GET|HEAD/ | | [email protected] | | |
| | GET|HEAD register | | [email protected] | | |
| | POST handleRegister | | Closure | | |
+--------+---------------------+------+------------------------------+----------------+---------------+
경로 파일 및 색인 조치를 지정하십시오. – itachi
나는 질문을 편집했다. :) – Jerielle
EmployeesController @ index의 코드가 맨 위에 내 인덱스 함수입니다. 나는 내 질문에 포함시켰다. – Jerielle