Home  >  Article  >  Backend Development  >  Detailed explanation of how to use Laravel to implement simple form submission

Detailed explanation of how to use Laravel to implement simple form submission

*文
*文Original
2018-01-03 11:34:291610browse

How to use Laravel to implement simple form submission? This article shares with you a simple example of how to implement form submission in the process of using laravel. It is very simple and is recommended here to friends who are learning laravel. I hope to be helpful.

First, make a simple form page

<html>
	<head>
	</head>
	<body>
		<form action="/submit" method="post">
			<input type="text" name="a"></input>
			<input type="text" name="b"></input>
			<input type="text" name="c"></input>
			<input type="submit"></input>
		</form>
	</body>
<html>

Edit a route

Route::post(&#39;/submit&#39;,&#39;FormController@store&#39;);

Create a controller

<?php

namespace App\Http\Controllers;

//use Illuminate\Http\Request;

use App\Http\Requests;
use Request;

class FormController extends Controller
{
  public function store(){
		//var_dump(Request::all());
		$input=Request::all();
		echo $input[&#39;a&#39;].PHP_EOL;
		echo $input[&#39;b&#39;].PHP_EOL;
		echo $input[&#39;c&#39;].PHP_EOL;
	}
}

Related recommendations:

Explore how Laravel’s middleware is implemented

Detailed explanation of how to implement Adding a custom global function in Laravel

Detailed explanation of how Laravel modifies .env configuration through the background

The above is the detailed content of Detailed explanation of how to use Laravel to implement simple form submission. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn