我在将所有数据发布到数据库后尝试重定向到另一个页面。我得到它发布数据而不去另一个视图,但现在我添加了它不会做的视图,我得到这个错误:
NotFoundHttpException in RouteCollection.php line 161:
这是我的routes.php文件
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::Get('/', function()
{
return View::Make('welcome');
});
Route::Get('registration', function()
{
return View::make('registration');
});
Route::post('registration', function()
{
$user = new \App\User;
$user->UserName = Input::get('UserName');
$user->Password = Hash::make(Input::get('password'));
$user->FirstName = Input::get('FirstName');
$user->LastName = Input::get('LastName');
$user->Gender = Input::get('Gender');
$user->Email = Input::get('Email');
$user->Q1 = Input::get('Q1');
$user->Q2 = Input::get('Q2');
$user->Q3 = Input::get('Q3');
$user->save();
return View::make('welcomepage');
});
任何建议都会很棒。
答案 0 :(得分:0)
在/
路线中,您的Make方法应为小写字母..
Route::get('/', function()
{
return View::make('welcome');
});
答案 1 :(得分:0)
以下是修改后的route.php
的示例。将用户保存到数据库后,它会将用户重定向到名为registrationsuccess
的页面。这是你想要的吗?
注意:您需要在resources/views/registrationsuccess.blade.php
下的模板中包含要在注册成功后显示的内容。
// Welcome page
Route::get('/', function()
{
return View::Make('welcome');
});
// Registration GET, with empty form
Route::get('registration', function()
{
return View::make('registration');
});
// Registration POST, with form content
Route::post('registration', function()
{
$user = new \App\User;
$user->UserName = Input::get('UserName');
$user->Password = Hash::make(Input::get('password'));
$user->FirstName = Input::get('FirstName');
$user->LastName = Input::get('LastName');
$user->Gender = Input::get('Gender');
$user->Email = Input::get('Email');
$user->Q1 = Input::get('Q1');
$user->Q2 = Input::get('Q2');
$user->Q3 = Input::get('Q3');
$user->save();
return redirect('registrationsuccess');
});
// Success page after registration
Route::get('welcomepage', function()
{
return view('welcomepage');
});