HTML submission Form, PHP in the background to get form content Method _ Example 1

Source: Internet
Author: User
Tags html form lua sublime text

HTML code:

  1. <html>
  2. <head>
  3. <meta http-equiv= "content-type" content= "text/html; Charset=utf8 ">
  4. <Title>this is a simple HTML form! </title>
  5. </head>
  6. <body>
  7. <form action="send_simpleform.php" method="POST" >
  8. Name:<input type="text" name="username" ><br>
  9. Select some products: <br>
  10. <Select name="products[]" size=6 multiple>
  11. <option value="C + +" >c++</option>
  12. <option value="C #" >c#</option>
  13. <option value="php" >php</option>
  14. <option value="Python" >python</option>
  15. <option value="Lua" >lua</option>
  16. <option value="JavaScript" >javascript</option>
  17. </select><br/>
  18. Message:<br>
  19. <textarea name="message" rows="5" cols="All" ></textarea> <br>
  20. <input type="Submit" value= "OK" >
  21. </form>
  22. </body>
  23. </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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.