Home  >  Article  >  Backend Development  >  A simple comprehensive application for php form submission to obtain data to the current page

A simple comprehensive application for php form submission to obtain data to the current page

伊谢尔伦
伊谢尔伦Original
2017-04-24 11:34:205625browse

Forms are a major external form for implementing dynamic web pages. Forms can be used to collect information submitted by clients. Forms are an important part of website interaction.

This section will provide a comprehensive example, which will integrate various components related to the form introduced in the previous chapter examples to achieve a comprehensive application of all components together. Mainly based on the "Inserting a form into an ordinary WEB page" in the previous chapter, PHP code is used to obtain the value of the form element. Submit the values ​​of each component to this page through the POST() method, and obtain the submitted values ​​through $_POST.

The specific operation steps are as follows:

(1) The HTML page design of the form is as follows, directly enter the code:




  
  Document

姓名:
性别:
密码:
学历:
爱好: 音乐 体育 美术
照片上传:
个人简介:

This form includes common form elements: Single-line text box, Multi-line text box, single option (radio), multiple option (checkbox), and multi-select menu.

The list box is a list menu, and its named attributes have their own values ​​for selection. Selected is a specific attribute selection element. If an option is attached with this attribute, the item will be listed as the first item when displayed.

The content in the intro text box displays the text, row and column width according to rows and cols.

The checked tag refers to a certain value in single option and multi-option, which has been selected by default.

(2) Process the data submitted by the form, so as to output the various submitted data entered in the form to the current page. The code is in the following format:

';
   echo "姓名:".$_POST['user'].'
'; //输出用户名 echo "性别:".$_POST['sex'].'
'; //输出性别 echo "密码:".$_POST['pwd'].'
'; //输出密码 echo "学历:".$_POST['select'].'
'; //输出学历 echo "爱好:"; for($i=0;$i"; $path = './upfiles/'.$_FILES['image']['name']; // 指定上传的路径和文件名 //move_uploaded_file($_FILES['image']['img_name'],$path); //上传文件 echo "照片:"."$path".'
'; //输出个人照片的路径 echo "个人简介:".$_POST['intro']; //输出个人简介的内容 } ?>

Description: About uploading For files or pictures, please refer to PHP Chinese website php $_FILES detailed explanation

(3) Create an upfiles folder in the root directory in the above example to store uploaded files.

(4) Enter the running address in the browser and press the Enter key to get the running result as shown below:

A simple comprehensive application for php form submission to obtain data to the current page

Summary: The above is For the comprehensive application of PHP and WBE forms, friends need to practice a lot. After mastering these technical points, you can apply the forms more freely, which means that you already have the ability to develop dynamic pages, laying a good foundation for the next step of in-depth learning of the PHP language.

The above is the detailed content of A simple comprehensive application for php form submission to obtain data to the current page. 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