路线/网络.php
Route::get('/','UserController@index');
Route::post('/index','UserController@store');
控制器:用户控制器.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Users;
class UserController extends Controller
{
public function index()
{
return view('index');
}
public function store(Request $request)
{
$user = new Users();
$user->fname = $request->input('fname');
$user->lname = $request->input('lname');
$user->email = $request->input('email');
$user->password = $request->input('password');
$user->save();
return redirect()->route('index')->with('info','User Added Successfully');
}
}
查看:索引刀片.php
@extends('layout.main')
@section('title','Index Page')
@section('content')
<div class="container">
<div class="row">
<form id="myform" action="{{route('store')}}">
@csrf
<div class="form-group">
<label for="fname">{{ trans('core.fname') }}</label>
<input type="text" class="form-control" id="fname" name="fname"/>
</div>
<div class="form-group">
<label for="fname">{{ trans('core.lname') }}</label>
<input type="text" class="form-control" id="lname" name="lname"/>
</div>
<div class="form-group">
<label for="fname">{{ trans('core.email') }}</label>
<input type="text" class="form-control" id="email" name="email"/>
繁华开满天机
小唯快跑啊
慕沐林林