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

Source: Internet
Author: User
Tags php language php form
Forms are a major external form of implementing dynamic Web pages that use forms to collect information submitted by clients. Forms are an important part of website interaction.

This section will provide a comprehensive example that will combine the various components of the form described in the previous chapter examples to achieve a comprehensive application of all components together. Based on the previous section, "Insert a form in a normal Web page", use PHP code to get the value of the form element. The value of each component is submitted to this page through the POST () method, and the value of the commit is obtained by $_post.

The specific steps are as follows:

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

<! DOCTYPE html>
<?php if ($_post[' Submit ']!= ") {           //To determine if the form was submitted with   echo" Your resume is: ". <br> ';   echo "Name:". $_post[' user ']. ' <br> ';      Output User name   echo "Gender:". $_post[' sex ']. ' <br> ';       Output gender   echo "Password:". $_post[' pwd ']. ' <br> ';       Output password   echo "Education:". $_post[' select ']. ' <br> ';    Output education   echo "hobby:";   for ($i =0; $i <count ($_post["fond"]), $i + +) {  //The value of the check box for the Hobby     echo $_post["fond"] [$i]. ' &nbsp; ';   }   echo "<br>";   $path = './upfiles/'. $_files[' image ' [' name '];    Specify the path and file name of the upload   //move_uploaded_file ($_files[' image ' [' img_name '], $path);   Upload file   echo "Photo:". " $path ". ' <br> ';              Output the path of a personal photo   echo "Profile:". $_post[' intro ';         Export the content of your profile}?>

Description: Please refer to topic.alibabacloud.comphp $_files for uploading files or images.

(3) Create a Upfiles folder in the root directory of the above example to store the uploaded files.

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

Summary: The above is the combination of PHP and WBE forms of application, friends need more practice, master These technical points, you can apply more freely to the form, meaning already have the ability to develop dynamic pages, for the next step in-depth study of PHP language to lay a good foundation.

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.