When we are designing web pages, we usually use the Get variable method in PHP to get the data from the form form, so that we can implement various Web page dynamic queries or requests. For a slightly HTML-based friend, you should know that there are two ways to submit the HTML form form is get and post, but for the novice small white, perhaps this knowledge point is somewhat blurred.
Then this article is mainly to give you a detailed introduction of the Get method is PHP through get variables to obtain form form data specific methods and usefulness, later in the article to continue to introduce the role of post specific usage.
Here's a sample code for you:
1. Form form code example (form get submit)
Effects such as:
2. test.php code (PHP receives get data)
<?phpheader ("Content-type:text/html;charset=utf-8"); Set the encoding?> welcome <?php echo $_get["fname"];?>!<br> you are <?php echo $_get["age";?> years old.
When you click the Submit button in code 1, the page appears as follows:
Here you can observe, what are the characteristics of the links in the browser address bar? It is not difficult to find that the information sent from a form with a GET method is displayed in the Address bar and is visible to anyone. That is, when you use method= "get" in an HTML form, all the variable names and values are displayed in the URL. (Note: test.php files can collect form data through $_get variables)
In summary: When sending passwords or other sensitive information, this method should not be used! However, because the variable parameter is displayed in the URL, you can bookmark the page in the Favorites folder. In some cases, it is also useful, such as the need to display some information directly to the user.
The above information about getting the form get parameter of PHP is helpful to friends who need it.