Difference Between GET and POST method form in php
PHP(Pre Processor Hypertext) used many global variables in their program
but the two global variables are use at the same time some of students confuse
during use of GET or POST method in html form.
Todays Article is much important why we use GET method in HTML form
and why we use POST method in HTML form.
First and foremost thing is why we use this Global Variables
When we retrieve data from html form we use some back end languages
and this article about PHP so we give the name of input of html
than we write a syntax in php field like
CODE
GET METHOD
<html>
<head>
<title></title>
</head>
<body>
<form method="GET" action="one.php">
<table>
<tr><td>Student ID</td> <td> <input type="input" name="a"></td></tr>
</table>
<input type="submit" name="submit">
</form>
</body>
</html>
<input>
<?php
//declare a variable name not same its just e..g just write the name of input
$Get=$_GET['a'];
//$_GET shows a data in your URL bar after clicking submit
//
?>
POST METHOD
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="POST" action="one.php">
<table>
<tr>
<td>Student ID</td> <td> <input type="input" name="a"></td></tr>
</tr>
</table>
<input type="submit" name="submit">
</form>
</body>
</html>
<input>
<?php
//declare a variable name not same its just e..g just write the name of input
$post=$_POST['a'];
//$_POST not shows data in your URL bar after clicking submit
//further details given
?>
POST METHOD
- POST requests are not and never cached
- POST requests do not copy in the browser history
- POST requests cannot copy as bookmarked
- POST requests have no restricted data length
- its data not show in url bar
GET METHOD
- GET requests are cached
- GET requests copy in the browser history
- GET rquests copy as bookmarked
- GET method always use to fetch data (show user id ,student id)
- Its data show on url's bar
Syntax
$_GET['a'];
$_POST['a']
No comments:
Post a Comment