HTML code:
- <html>
- <head>
- <meta http-equiv= "content-type" content= "text/html; Charset=utf8 ">
- <Title>this is a simple HTML form! </title>
- </head>
- <body>
- <form action="send_simpleform.php" method="POST" >
- Name:<input type="text" name="username" ><br>
- Select some products: <br>
- <Select name="products[]" size=6 multiple>
- <option value="C + +" >c++</option>
- <option value="C #" >c#</option>
- <option value="php" >php</option>
- <option value="Python" >python</option>
- <option value="Lua" >lua</option>
- <option value="JavaScript" >javascript</option>
- </select><br/>
- Message:<br>
- <textarea name="message" rows="5" cols="All" ></textarea> <br>
- <input type="Submit" value= "OK" >
- </form>
- </body>
- </html>
PHP Code:
<?phpheader("Content-Type: text/html; charset=UTF-8");if (isset($_POST["username"])){echo "输入的名户名为:" . $_POST["username"] . "<br>";}if (isset($_POST["products"])){if (is_array($_POST["products"]) && !empty($_POST["products"])){echo "选择的科目为:" . "<br>";foreach ($_POST["products"] as $value ) {echo
Note: In the example above, the apache+php environment needs to be set up and the Apache service is guaranteed to start.
When you create a file to save the above code, do not use Notepad, if the Chinese display in Notepad seems to have a problem, here I recommend a software (Sublime Text 3), with the tool, create a new file, then save the corresponding file format, and then enter the HTML address in the browser, Here I use my own example to illustrate, enter the following address:
Localhost/simpleform.html
After entering the data, click OK, display the following content, the content is PHP in the background processing results
HTML submission Form, PHP in the background to get form content Method _ Example 1