Home > Backend Development > PHP Tutorial > How to get the values ​​of multiple input elements with the same name in a form in php

How to get the values ​​of multiple input elements with the same name in a form in php

怪我咯
Release: 2023-03-13 14:56:02
Original
2307 people have browsed it

Sometimes the front page needs to allow dynamic addition/deletion of multiple values ​​of a certain attribute, such as adding books to the bookshelf, and it must be possible to dynamically add or delete books.

There will be multiple input elements in the form of the front page, as follows:

<form action="a.php"> 
<input type="text" name="books[]"/> 
<input type="text" name="books[]"/> 
<input type="text" name="books[]"/> 
<input type="submit" name="submit" /> 
</form>
Copy after login

When the a.php page receives the form data, you can use $books = $_REQUEST['books'] ;Get the array of all book titles.

The above is the detailed content of How to get the values ​​of multiple input elements with the same name in a form in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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