Home > Backend Development > PHP Tutorial > Array form submission, array form submission_PHP tutorial

Array form submission, array form submission_PHP tutorial

WBOY
Release: 2016-07-13 10:09:45
Original
1676 people have browsed it

Array form submission, array form submission

I encountered a problem today. I had to save a lot of form information. After worrying about it for a long time, I finally found a pretty good way to use an array. Submit the data in the form to the background for saving.

In fact, it is very simple to implement, that is, there must be certain standards when naming the information to be submitted in the form. Let us first compare the differences between the following two methods:

The first, common way, each value to be submitted has a name

<form id="form1" action="./index.php" method="get">
	<div class="form-control">
		<input type="text" name="name1" />
		<input type="text" name="num1" />
		<input type="text" name="img1" />
	</div>
	<br>
	<div class="form-control">
		<input type="text" name="name2" />
		<input type="text" name="num2" />
		<input type="text" name="img2" />
	</div>
	<br>
	<div class="form-control">
		<input type="text" name="name3" />
		<input type="text" name="num3" />
		<input type="text" name="img3" />
	</div>
	......
  <input type="submit" value="Submit" />
</form>
Copy after login

The service (index.php) is as simple as two sentences

<?php
echo "<pre class="brush:php;toolbar:false">";
print_r($_GET);
Copy after login

Fill in the following information on the rendered webpage and click submit

Array form submission, array form submission_PHP tutorial



...

If you look carefully, you will find that the name of the data to be submitted has changed. It may not be obvious here. When you click submit, you will find that the values ​​​​passed to the backend are much neater. Take a look at the screenshot below

The query string parsed through the browser plug-in is like this

Array form submission, array form submission_PHP tutorial



...

First look at the data passed by the browser

 Array form submission, array form submission_PHP tutorial The copyright of this article belongs to the author iforever (luluyrt@163.com). Any form of reprinting is prohibited without the author's consent. After reprinting the article, the author and the original text link must be given in an obvious position on the article page, otherwise we will reserve the right to pursue it. Legal liability rights.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/942278.htmlTechArticleSubmit the form in array mode. I encountered a problem when submitting the array form today. I have to save a lot of form information. I have been worrying about it for a long time. , finally found a pretty good method, in the form of an array...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template