Please note, this is a STATIC archive of website technosmarter.com from July 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
 

GET method in PHP


The data from the server is displayed on the web browser. It's simple to process without PHP codes. You do not need to create a dynamic website for this, but if the client wants to send information to the server then static codes do not work. To send data to the server, you have to create a dynamic form for which the client can fill their information and send to the server.PHP has two methods to help you send your data to the server.

1. GET Method

2.Post method

In this PHP tutorial, we will discuss the GET method. When the client fills data in an HTML form, before going information on the server, the information encoded with the help of a scheme URL encoding, then the information goes to the server. We can handle this complete process with the GET Method and Post method.

GET Method in PHP

We have discussed the above that with the help of the GET and POST method, the user can send information to the server by encoding. When a client sends the information, then the client information appended to the page request. If you check page URL, the encoded information separated by? (Question mark). You can see the encoded information in the URL separated by the?

    
https://example.com/home.php?user=john&pass=john123&submit=Submit

Syntax

 

$_GET['varibale_name'];

In the above syntax, $ _GET[ ..] is an array of PHP and within the array, you have to use the name of the variable. Variable Name - Name of the variable. Use any variable name for form values. When you create a login form, you define some variables that bring values from the form. We pass the variables inside the $_GET[..] are encoded with the help of the GET method.

Example of GET method

In the below example, we create a simple HTML form. In the HTML form, we create two text boxes and a submit button. If the user clicks on the submit button, then the form information transfer to the server by encoded GET method through the variables name. In the PHP script, we use the username and password inside the $_GET[..] array. In simple words- You can see the submitted information in the URL separated by the? Let's implement the example of the GET method.

Example

<html>
<head>
</head>
<body>
<form action="" method="GET">
User Name:

Password:



</body>
</html>
<?php 
if(isset($_GET['submit']))
{
	
 $user=$_GET['user'];
$pass=$_GET['pass'];
echo $user; 
echo "
"; echo $pass; } ?>

Run this example on Local server or global server.

Enter user name = sem

Enter password= 123sem

It produces this output -

 

https://localhost/home.php?user=sem&pass=123sem&submit=Submit

In the output of this example, you can see that the username(sem) and password(123sem) are showing in the URL.So this is done by the GET method that shows the information within page URL separated by?

Note- We do not use the GET method insensitive case (password,user,information).

More about GET Method

These points will help you easily understand the GET method.

1. The restriction of GET method is that it sends up to 1024 character only.

2. The PHP provides $_GET associative array to access all the sent information.

3. You cannot use GET method to send binary data, like the image or documents, to the server .

4. There is no security with the GET method if you have a password or other sensitive information to be sent.

5. Values are visible in page URL.

6. The GET method supports only string data type. The strings displayed in the URL .

7. Never use GET method if you are working for sensitive information system like - login, registration, etc .


Please Share

Recommended Posts:-