GET method in PHP
GET method in PHP: – The browser communicates with the server using two HTTP methods — GET and POST pass the information different way.PHP communicates with the server or sent information to the server using Two Method Either GET or POST Method.
TWO METHODS OF SENDING INFORMATION TO SERVER
Explain GET METHOD:-
GET is for retrieving data. With a GET method, you are sending your data Through the URL and also Requests data from a specified resource.Use of Getting in the form of its home page because the result must be easily bookmarked and shareable.
These are the points is about the get how to work and process:-
- GET requests can be cached.
- GET requests remain in the browser history.
- GET requests can be bookmarked.
- GET requests should never be used when sending the sensitive data over the server.
- GET requests have length restrictions(255 BYTES).
- GET method can’t be used to send binary data, like images or word documents, to the server or any other pages. The data or information sent by GET Form Method can be accessed or used using a QUERY_STRING environment variable. The PHP provides $_GET associative array to access all the sent information by URL using GET Method in PHP.
SYNTAX Of GET method:-
Here you see using the GET Form method how to sending the information to the server.
CREATE A FORM IN HTML.
<html> <body> <form action="setvalue.php" method="get"> <input type="text" name="user_name" placeholder="enter a name"> <br> <input type="text" name="user_email" placeholder="enter a email"> <br> <input type="submit" value="submit"> </form> </body> </html>
CREATE PAGE IN PHP.
CREATE THE ANOTHER PAGE with name setvalue.php TO GET THE INFORMATION OF USER SENT THROUGH URL USING GET METHOD.
<?php $username=$_GET['user_name']; $email=$_GET['user_email']; echo '<h1>I have recieved value from user </h1>'; echo $username.'<br/>'; echo $email; ?>
You see it the data send over the server by using GET Method is not secure they are easily visible.
I hope you would like this topic on GET method in PHP