Apply HTML forms with PHP

Source: Internet
Author: User
The ability to easily control information submitted by users through HTML forms has always been one of the top advantages of PHP. In fact, PHP version 4.1 adds several new methods to access this information and effectively removes the most commonly used methods in previous versions. This article is one of the top advantages of PHP to easily control the information submitted by users through HTML forms. In fact, PHP version 4.1 adds several new methods to access this information and effectively removes the most commonly used methods in previous versions. This article studies different methods for applying information submitted on HTML forms, and also applies earlier PHP versions and newer versions. This article first starts from studying a single value, and then constructs a page that can visit any available form value in general.

Note: This document assumes that you have the right to visit the Web service running PHP version 3.0 or later. You need to have a basic understanding of PHP and the creation of HTML forms.

HTML form

When you browse this article, you will see how different types of HTML form elements provide PHP access information. In this example, I applied a simple information form consisting of two text fields, two check boxes, and a multiple-choice box:

Listing 1. HTML form



Tour Information



Mission Information







If no method is specified, the form applies the default GET method, and the browser uses it to append the form value to the URL, as shown below:

Http://www.vanguardreport.com/formaction.php?

Ship = Midnight Runner & tripdate = 12-15-2433 & Authentication = yes & crew = snertal & crew = gosny

Figure 1 shows the form itself.

Figure 1. HTML form

Old measure: Visit global variables

The code shown in listing 2 treats the form value as a global variable:

Listing 2. form values as global variables


Echo 'ship = '. $ Ship;

Echo'
';

Echo 'tripdate = '. $ Tripdate;

Echo'
';

Echo 'annotation = '. $ annotation;

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.