Php form submission

Source: Internet
Author: User
Tags php form
This article mainly introduces two methods and simple examples of php form submission, which are very practical and can be referenced by other users. Process GET requests

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

Create HTML file hello.html:

  
   Welcome

Create the php file hello. php:

<? 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 it is not empty, echo 'hello '. $ _ GET ['name'];} else {echo 'Please input name ';}

The Get request explicitly places the form data in the URI and has restrictions on the length and data value encoding, such as http: // 127.0.0.1/hello. php? Name = Vito

Process POST requests

Implement a simple addition operation

Create HTML file add.html:

  
   Add

Create the php file add. php:

<?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';}

The Post request places the form data in the http request body without the length limit.

Form action = "" means: form is the form, action is the redirection address, that is, where the form must be submitted

The above is all the content of this article. I hope you will like it.

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.