How to get get data in php?

青灯夜游
Release: 2023-02-26 18:20:02
Original
8391 people have browsed it

How to get get data in php?

In PHP, if you want to obtain the data submitted through the get method, you can obtain it through the $_GET object (although the parameters can be viewed in the address bar)

$_GET variable

The predefined $_GET variable is used to collect values ​​from the form with method="get".

The information sent from a form with the GET method is visible to anyone (will be displayed in the browser's address bar), and there is a limit on the amount of information sent.

Example:

HTML code: The following is a simple form code to submit data to 01.php, using the get method

<form action="01.php" method="get" >
  <label for="">姓名:
      <input type="text" name= "userName"></label>
      <br/>
  <label for="">邮箱:
      <input type="text" name= "userEmail"></label>
      <br/>
      <input type="submit" name="">
</form>
Copy after login

PHP code:

<?php 
    echo "<h1>GET_PAGE</h1>";
    echo &#39;userName:&#39;.$_GET[&#39;userName&#39;];
    echo &#39;<br/>&#39;;
    echo &#39;userEmail:&#39;.$_GET[&#39;userEmail&#39;];
 ?>
Copy after login

How to get get data in php?

When to use method="get"?

When using method="get" in an HTML form, all variable names and values ​​will be displayed in the URL.

Note: So this method should not be used when sending passwords or other sensitive information!

However, because the variable appears in the URL, it is possible to bookmark the page. In some cases this is useful.

Note: The HTTP GET method is not suitable for large variable values. Its value cannot exceed 2000 characters.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to get get data in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!