please click here for more wordpress cource
In PHP, GET and POST are two common HTTP methods used to send data from a client (such as a web browser) to a server. Both GET and POST methods are used to submit data to a server, but they differ in how they do it.
GET method:
- The GET method sends data to the server through the URL of the webpage. This means that the data is visible in the address bar of the browser.
- GET method is used to retrieve data from the server, such as a webpage or an image.
- The GET method has a limit on the amount of data that can be sent (usually around 2048 characters).
Example:
<form action="process.php" method="get">
Name: <input type="text" name="name"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Submit">
</form>
When the form is submitted, the data will be sent to “process.php” as a query string in the URL. For example: process.php?name=John&email=john@example.com
POST method:
- The POST method sends data to the server in the body of the HTTP request, which is not visible in the address bar of the browser.
- POST method is used to submit data to the server, such as a form that contains sensitive information like a password or credit card details.
- The POST method has no limit on the amount of data that can be sent.
Example:
<form action="process.php" method="post">
Name: <input type="text" name="name"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Submit">
</form>
When the form is submitted, the data will be sent to “process.php” in the HTTP request body, rather than in the URL. The data can be accessed in PHP using the $_POST
superglobal array, like this:
$name = $_POST['name'];
$email = $_POST['email'];