Difference Between Get and Post in Tabular Form
| Sno. | Basic Term | Get | Post |
| 1. | Definition | Requests data from a specified resource | Submits data to be processed to a specified resource. |
| 2. | Variables in Php | $_GET | $_POST |
| 3. | Data length | 2048 characters | No Limit |
| 4. | Security | Less Security Urls saved in browser history and server logs in plaintext. | More Secure No saved in browser history and server logs in plaintext. |
| 5. | Displayed in Url | Yes | No. |
| 6. | Bookmarked | Yes | No. |
| 7. | History | Yes Saved in history | No. |
| 8. | Encoding Type(enctype attribute) | application/x-www-form-urlencoded | application/x-www-form-urlencoded or multipart/form-data |
| 9. | Url Example | http://www.example.com/action.php?name=Abhi&age=22 | http://www.example.com/action.php |
| 10. | Cached | cached | Never |
| 11. | Send Sensitive Data | No | Yes |
| 12. | BACK button/Reload | Same Link is Reload and Then Process | Before Reload browser should alert about the re-submitted data |
| 13. | Data Type | Only ASCII characters allowed and non ASCII characters are Not Alow like (©, ®,™)etc | No restrictions. Binary data is also allowed |
| 14. | Using | Used with Action
| POST method used with.
|
| 15. | Form Submission In Php Example | <?php
$name="";
$age="";
$active=false;
if(isset($_GET["submitform"])){
$name = $_GET["name"];
$age = $_GET["age"];
$active=true;
}
?>
<form method="get">
<input type="text" name="name" placeholder="Enter Name " />
<input type="number" name="age" placeholder="Enter Age " />
<input type="submit" name="submitform" placeholder="Enter Age "/>
</form>
<?php
if($active){
echo "Name is ".$name." and age is ".$age;
}
?>
| <?php
$name="";
$age="";
$active=false;
if(isset($_POST["submitform"])){
$name = $_POST["name"];
$age = $_POST["age"];
$active=true;
}
?>
<form method="post">
<input type="text" name="name" placeholder="Enter Name " />
<input type="number" name="age" placeholder="Enter Age " />
<input type="submit" name="submitform" placeholder="Enter Age " />
</form>
<?php
if($active){
echo "Name is ".$name." and age is ".$age;
}
?>
|
(Visited 1,585 times, 1 visits today)
Written by: