On the _php tutorial of PHP submitting form forms

Source: Internet
Author: User

Talking about PHP submitting form form


This article mainly introduces the 2 kinds of methods and simple examples of submitting form form in PHP, which is very practical and can be referred to by small partners.

Handling GET Requests

The function implemented is to enter the name after the page displays "Hello XXX"

To create an HTML file hello.html:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

Welcome

Create PHP file hello.php:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

/**

* 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 ';

}

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

Processing 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

Add

Create PHP file add.php:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

/**

* 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 ';

}

The POST request places the form data in the HTTP request body with no length limit

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

The above mentioned is the whole content of this article, I hope you can like.

http://www.bkjia.com/PHPjc/1025319.html www.bkjia.com true http://www.bkjia.com/PHPjc/1025319.html techarticle A brief talk on PHP submitting form form This article mainly introduces the 2 kinds of methods and simple examples of submitting form form in PHP, which is very practical and can be referred to by the small partners. Handling Get please ...

  • 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.