php get and post methods,php difference between get and post method,php get post request method
php get and post methods,php difference between get and post method,php get post request method
PHP GET and POST methodology – phptaab
While addressing the forms, info are often submitted and transferred to same or another page. To send submitted information through type, one will use GET & POST methodology to try to to that in PHP.
A type information are often submitted exploitation these 2 ways. each area unit used for same purpose however stands apart below some specifications. As in GET methodology key values area unit passed within the uniform resource locator whereas in POST, the data transfers during a hidden manner.
A type submitted info is appended in to the uniform resource locator within the variety of question String consisting of name=value pairs in uniform resource locator. This string contains user values/data, that area unit separated by punctuation and areas area unit replaced with + sign.
We have lined heap of examples during which, we tend to set methodology attribute of type to urge or POST. Let’s discuss regarding them in details.
> GET methodology
As explained higher than, before causing any info , it converts values/data into a question string in uniform resource locator called uniform resource locator secret writing. that contains each page link and encoded info separated by the ? character.
Client Side: Below code is AN hypertext markup language type with method=”get” for user to fill info.
Server Side: Below code has PHP script wherever, $_GET associative array is employed to receive sent info at server finish.
PHP GET and POST methodology – phptaab
While addressing the forms, info are often submitted and transferred to same or another page. To send submitted information through type, one will use GET & POST methodology to try to to that in PHP.
A type information are often submitted exploitation these 2 ways. each area unit used for same purpose however stands apart below some specifications. As in GET methodology key values area unit passed within the uniform resource locator whereas in POST, the data transfers during a hidden manner.
A type submitted info is appended in to the uniform resource locator within the variety of question String consisting of name=value pairs in uniform resource locator. This string contains user values/data, that area unit separated by punctuation and areas area unit replaced with + sign.
We have lined heap of examples during which, we tend to set methodology attribute of type to urge or POST. Let’s discuss regarding them in details.
> GET methodology
As explained higher than, before causing any info , it converts values/data into a question string in uniform resource locator called uniform resource locator secret writing. that contains each page link and encoded info separated by the ? character.
Client Side: Below code is AN hypertext markup language type with method=”get” for user to fill info.
<form action="#" method="get">
<input type="text" name="name" placeholder="Your Name"></input><br/>
<input type="text" name="email" placeholder="Your Email"></input><br/>
<input type="text" name="contact" placeholder="Your Mobile"></input><br/>
<input type="submit" name="submit" value="Submit"></input>
</form>
Server Side: Below code has PHP script wherever, $_GET associative array is employed to receive sent info at server finish.
<?php
if( $_GET["name"] || $_GET["email"] || $_GET["contact"])
{
echo "Welcome: ". $_GET['name']. "<br />";
echo "Your Email is: ". $_GET["email"]. "<br />";
echo "Your Mobile No. is: ". $_GET["contact"];
}
?>
Above question string of data, generated by Get technique are often clear in address bar so, ne'er use Get technique for causation sensitive data to server.
One ought to avoid use of this technique to send binary knowledge like, pictures or Word Document file to the server.
> POST technique
As explained on top of, before causation data to server, it converts client’s data into a question string in computer address.
Client Side: Below code is Associate in Nursing markup language type with method=”post” for user to fill data.
<form action="#" method="post">
....
</form>
Server Side: Below code has PHP script wherever, $_POST associative array is employed to receive sent data at server finish.
<?php
if( $_POST["name"] || $_POST["email"] || $_POST["contact"])
{
echo "Welcome: ". $_POST['name']. "<br />";
echo "Your Email is: ". $_POST["email"]. "<br />";
echo "Your Mobile No. is: ". $_POST["contact"];
}
?>
Query string , generated by Post technique ne'er seems in address bar i.e. it's hidden for the user so, we will use this technique for causation sensitive data to server. Moreover, we will create use of this technique to send binary knowledge to the server with none restrictions to knowledge size.
In our example, we have a tendency to enable user to settle on {a technique|a way|a technique} via radio button and this price is appointed to form’s method attribute.
$("input[type=radio]").change(function(){
var method = $(this).val();
$("#form").attr("method", method); // Assigns Method Type From Radio Button
});
Category:
0 comments