TWO METHODS OF SENDING INFORMATION TO SERVER:-
The browser communicates with the server using two HTTP methods — GET and POST pass the information different way.PHP communicates with server or sent information to the server using Two Method Either GET or POST Method
POST method in PHP:-
POST method is a request method supported by the HTTP protocol used by the World Wide Web. POST request, an amount of data of any type can be sent to the server.The POST method does not have any restriction on data size to be sent. By using Secure POST method you can make sure that your information is secure.Since the data sent by the POST form method is not visible in the URL, so it is not possible to bookmark the page with a specific query.
These are the points is about the get how to work and process:-
- POST requests are never cached.
- POST requests do not remain in the browser history.
- POST requests cannot be bookmarked.
- POST requests have no restrictions on data length.
- POST form method can be used to send binary data, like images or word documents, to the server or any other pages. The data or information sent by POST Form Method can be accessed. The PHP provides $_POST associative array to access all the sent information using POST Form Method.
Here you see using the POST method how to sending the information to the server.
CREATE A FORM IN HTML.
<html> <body> <form action="setvalue.php" method="post"> <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
Now create a page in PHP with name setvalue.php and copy below code to receive data sent by Post method.We use S_POST associative array to receive data here and store data in variable
<?php $username=$_POST['user_name']; $email=$_POST['user_email']; echo '<h1>I have recieved value from user </h1>'; echo $username.'<br/>'; echo $email; ?>
You see it the data send over the sever by using POST method is secure .They are not visible.