Simple and comprehensive application of php form submission to get data to the current page

Source: Internet
Author: User
Tags php form
Form is a major external form for implementing dynamic web pages. using forms can collect information submitted by the client. Forms are an important part of website interaction. Form is a major external form for implementing dynamic web pages. using forms can collect information submitted by the client. Forms are an important part of website interaction.

This section provides an example of integration. it combines various components related to the form described in the examples in the previous chapter to implement the integrated application of all components. This section describes how to use PHP code to obtain the value of a form element based on "insert a form in a common WEB Page. Use the POST () method to submit the values of each component to this page and use $ _ POST to obtain the submitted values.

The procedure is as follows:

(1) form HTML page design:

  
   Document

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

A list box is a list menu with its own values under its naming attributes. Selected is a specific attribute selection element. If an option is attached with this attribute, this attribute is listed as the first item during display.

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

The checked tag refers to a value in a single option and multiple options. it is selected by default.

(2) process the data submitted by the form, and output the submitted data in the form to the current page. the code is as follows:

 '; Echo "name:". $ _ POST ['user'].'
'; // Output username echo "gender:". $ _ POST ['sex'].'
'; // Output gender echo "password:". $ _ POST ['pwd'].'
'; // Output password echo "education:". $ _ POST ['select'].'
'; // Output educational background echo "hobbies:"; for ($ I = 0; $ I "; $ Path = '. /upfiles /'. $ _ FILES ['image'] ['name']; // specify the upload path and file name // move_uploaded_file ($ _ FILES ['image'] ['IMG _ name'], $ path); // upload the file echo "Photo: ". "$ path ".'
'; // Output the path of the personal photo echo "profile:". $ _ POST ['Intro']; // output the profile content}?>

Note: for details about uploading FILES or images, refer to PHP _ FILES.

(3) Create an upfiles folder under the root directory of the above instance to store uploaded files.

(4) enter the running address in the browser and press enter to obtain the running result as shown in:

Conclusion: The above is the comprehensive application of PHP and WBE forms. friends need to practice more and master these technical points to be able to freely use form applications, which means they already have the ability to develop dynamic pages, it lays a good foundation for the next step of in-depth learning the PHP language.

The above is the detailed content of a simple integrated application that submits php forms to obtain data on the current page. For more information, see other related articles in the first PHP community!

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.