我是 laravel 的新手,现在我在做一些小项目。我有一个表单,在按下提交按钮后,我收到此错误消息“抱歉,找不到您要查找的页面。”
我的代码有什么问题吗?请帮我解决这个问题,这样我就可以继续这个项目。
谢谢指教
查看刀片,我将其命名为 index.blade.php
<div class="col m7 s12">
<form method="submit" action="post">
{{ csrf_field() }}
<div class="card-panel">
<h5>Please Fill Out This Form</h5>
<div class="input-field">
<input type="text" name="name" id="name" required class="validate">
<label for="name">Name</label>
</div>
<div class="input-field">
<input type="email" name="email" id="email" class="validate">
<label for="email">Email</label>
</div>
<div class="input-field">
<input type="text" name="phone" id="phone">
<label for="phone">Phone</label>
</div>
<div class="input-field">
<textarea name="message" id="message" class="materialize-textarea"></textarea>
<label for="message">Message</label>
</div>
<button type="submit" class="btn" blue darken-1>Send</button>
</div>
</form>
控制器,我将它命名为 LayoutController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
class LayoutController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
return view('layouts/index');
}
public function submit(Request $request)
{
$name = $req->input('name');
$email = $req->input('email');
$phone = $req->input('phone');
$message = $req->input('message');
$data = array('name'=>$name,"email"=>$email,"phone"=>$phone,"message"=>$message);
$data->save();
return Redirect::to('/layouts/index');
}
路由 web.php
Route::get('/', 'LayoutController@index');
Route::post('/submit', 'LayoutController@submit');
缥缈止盈
守着一只汪
烙印99