How to use super global variables $_POST and $_GET

王林
Release: 2023-03-03 19:06:01
forward
2336 people have browsed it

How to use super global variables $_POST and $_GET

PHP $_POST is widely used to collect form data. Specify this attribute in the HTML form tag: "method="post".

PHP $_GET is also used Widely used to collect form data, specify this attribute in the HTML form tag: "method="get".

(Recommended tutorial:php graphic tutorial)

Example:

The following example shows an input field (input) and submit button (submit ) form. When a user submits form data by clicking the "Submit" button, the form data is sent to the script file specified in the action attribute of the

tag.

In this example, we specify the file to process the form data. If you want another PHP file to handle this data, you can modify the specified script file name. We can then use the super global variable $_POST to collect the input field data in the form.

   Name:     
Copy after login

(Video tutorial recommendation:php video tutorial)

$_GET can also collect the data sent in the URL.

Suppose we have a hyperlinked HTML page containing parameters:

  Test $GET  
Copy after login

When the user clicks on the link "Test $GET", the parameters "subject" and "web" will be sent to "test_get.php ",You can use the $_GET variable in the "test_get.php" file to get this data.

The following example shows the code of the "test_get.php" file:

    
Copy after login

The above is the detailed content of How to use super global variables $_POST and $_GET. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!