A brief introduction to PHP submitting Form form

Source: Internet
Author: User
Tags http request php file php form

This article mainly introduces the introduction of PHP form 2 methods and simple examples, very practical, the need for small partners can refer to.

Handling GET Requests

The implementation of the function is to enter the name after the page display "Hello XXX"

To create an HTML file hello.html:

?

1 2 3 4 5 6 7 8 9 10 11 12-13 <! DOCTYPE html>

Create PHP file hello.php:

?

1 2 3 4 5 6 7 8 9 10 11 12-13 <?php/** * Created by Phpstorm. * User:administrator * DATE:2015/6/30 * time:15:03/Header ("content-type:text/html; Charset=utf-8 "); if (isset ($_get[' name ')) &&$_get[' name '] {//If there is a value and is not empty echo ' Hello '. $_get[' name ';} else{echo ' please input name ';}

The GET request places the form's data explicitly in the URI and limits the length and data value encoding, such as: Http://127.0.0.1/hello.php?name=Vito

Process POST Requests

Implementation of a simple addition operation function

To create an HTML file add.html:

?

1 2 3 4, 5 6 7 8 9 10 11 12 13 14 15 <! DOCTYPE html>

Create PHP file add.php:

?

1 2 3 4 5 6 7 8 9 10 11 12 13-14 <?php/** * Created by Phpstorm. * User:administrator * DATE:2015/6/30 * time:18:02/if ($_post[' num1 ']&&$_post[' num2 ']) {echo $_post[' NUM1 ']+$_post[' num2 ']; }else{echo ' please input num ';}

Post requests place form data in the HTTP request body with no length limit

Form action= "" means: Form is the forms, action is to address, that form form needs to be submitted to where

The above mentioned is the entire content of this article, I hope you can enjoy.

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.