What is a php form? How to create a PHP form (instance)

Source: Internet
Author: User
Tags php form
A php form is an area that contains form elements, and a form can be created by using the <form> tag and inserting related form elements into it. Here I will give you specific to analyze how the form is created.

Form elements are elements that allow users to enter information in a table consignments (such as a text field, drop-down list, radio box, check box, and so on).

The form is defined using the form label (<form>).

<form action= "script.php" method= "POST" > </form>

In the case of PHP, the most important attribute of the form tag is the action, which specifies which page the form data will be sent to, and the null is the page that contains the form, which is the current page;
The second property is method, which specifies how the data is sent to the processing page, and two options (get and Post) indicate the HTTP method to use.

Method Selection:

The Get method is to send the submitted data to the receiving page via a series of (name-value) pairs appended to the URL. For example:
Http://www.example.com/script.php?name=Homer&gender=M&age=35

Unfortunately, the amount of data transmitted through get is limited, and it is not very secure (because the data is visible).

Generally, get is used to request information, such as a specific record in a database or a search result (search almost always uses get).

Use the Post method when you need to take an action, such as when updating a database record or sending an e-mail message.

For these reasons, I generally use post, and if there are exceptions, I will say otherwise.

Now let's create a simple form, because this file does not contain PHP code, so my file is saved as (. html) suffix, of course, you can also use the (. php) suffix.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

This form is ready, and the final one is as follows:

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.