Home > Backend Development > PHP Tutorial > php $_POST to get html form data tutorial_PHP tutorial

php $_POST to get html form data tutorial_PHP tutorial

WBOY
Release: 2016-07-20 11:10:57
Original
1271 people have browsed it

The $_POST variable is used to collect values ​​from the form with method="post". Information sent from a form with the POST method is invisible to anyone (it does not appear in the browser's address bar), and there is no limit on the amount of information sent.

Let’s look at the simplest example first

The code is as follows Copy code
 代码如下 复制代码


Name:


Name:

If I enter hello,

post.php file code is as follows
 代码如下 复制代码

You are .

The code is as follows Copy code

You are .

The output result is

You are Hello

 代码如下 复制代码


Apple

Orange

Mango


So how do you get a post like a radio button? An example is as follows

The code is as follows Copy code

Apple

Orange
Mango


 代码如下 复制代码

radiopost.php file

The code is as follows Copy code
 代码如下 复制代码


Apple

Orange

Mango


In this way, if you choose which one, all the values ​​of that one will be output. It will be different for checkbox. You can pay attention to this. Click
The code is as follows Copy code

Apple

Orange

Mango


checkboxpost.php文件

 代码如下 复制代码
 代码如下 复制代码

print_r($_POST['abcde']);

print_r($_POST['abcde']);

The output is in the form of an array

Note:
Variables sent via HTTP POST will not be displayed in the URL.
There is no length limit for variables.

$_POST and php://input can get the value, $HTTP_RAW_POST_DATA is empty
$_POST organizes the submitted data in an associative array, and performs encoding processing on it, such as urldecode, and even encoding conversion .
php://input can obtain unprocessed POST raw data through file reading through the input stream

php://input allows reading POST raw data. It puts less pressure on memory than $HTTP_RAW_POST_DATA and does not require any special php.ini settings. php://input cannot be used with enctype="multipart/form-data".
Expand the post simulation method here

http://www.bkjia.com/PHPjc/444695.html
The code is as follows Copy code

$flag = 0; '=>'You Okay'); .= "&";                                                                                         g = 1;
}                                                                                                                              or exit ($errstr."--->".$errno);                                                                                                                         .= "Host:127.0.0.1";    
 $header .= "Referer:/mobile/sendpost.php";     
  $header .= "Content-Type: application/x-www-form-urlencoded" ; = $params.""; "
" //Send post data $ Line = fgets ($ fp, 1024); // Remove the header of the request package only display the return data of the page
IF ($ inheader && ($ line == "n" || $ line == "" "" "" )) {                                                                          echo $line;
}}                                                                                       

www.bkjia.comtrue
http: //www.bkjia.com/PHPjc/444695.html

TechArticle

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template