Page 1 of 1

GET and POST Explained Simply

Posted: Thu Apr 23, 2026 8:26 pm
by MegaTux
When beginners start learning HTML and PHP, they often come across the terms GET and POST. At first, they may sound confusing, but the basic idea is actually simple. GET and POST are two common methods used to send data from a browser to a web server.

A good example is a form on a website. If a user fills out a search box, a login form, or a contact form, that information needs to be sent somewhere. This is where GET and POST come in. They define how the data is sent.

What is GET?

With GET, the data is sent in the URL.

For example, if someone searches for “linux” on a website, the URL might look like this:

/search.php?query=linux

Here, the value linux is sent as part of the web address.

GET is useful when:

the request is simple
the data is not sensitive
the result should be easy to bookmark or share
you want parameters visible in the URL

Typical examples:

search forms
filter options
page numbers
category links

In PHP, GET data is usually read with:

$_GET['query']


What is POST?

With POST, the data is sent in the body of the request, not in the URL.

This means the information is not directly visible in the browser address bar.

POST is useful when:

the form sends sensitive data
the user submits longer information
the action changes something on the server
the data should not appear in the URL

Typical examples:

login forms
registration forms
contact forms
file uploads
changing account settings

In PHP, POST data is usually read with:

$_POST['username']

A Simple HTML Example

Here is a basic form using GET:

Code: Select all

<form action="process.php" method="get">
    <label>Search:</label>
    <input type="text" name="query">
    <button type="submit">Send</button>
</form>
And here is the same idea using POST:

Code: Select all

<form action="process.php" method="post">
    <label>Name:</label>
    <input type="text" name="name">
    <button type="submit">Send</button>
</form>
PHP Example

If the form uses GET:

Code: Select all

<?php
echo $_GET['query'];
?>
If the form uses POST:

Code: Select all

<?php
echo $_POST['name'];
?>
Main Difference

The easiest way to remember it is this:

GET = data goes in the URL
POST = data goes in the request body

Is POST More Secure?

Many beginners think POST is automatically secure. That is not fully true. POST hides data from the URL, but it does not encrypt it by itself. Real protection comes from using HTTPS and proper server-side validation.

So while POST is better for passwords and private data, it is not magic security on its own.

When Should You Use Which One?

Use GET when:

you want users to share or bookmark the link
the request only fetches data
the data is not private

Use POST when:

the user sends private or important data
the request changes something
you submit forms like login, register, or contact
Conclusion

GET and POST are both important and very common in web development. GET is usually used for reading or requesting information, while POST is often used for submitting or changing data. Once beginners understand this difference, working with forms in HTML and PHP becomes much easier.

In short:

GET is for visible request data in the URL.
POST is for sending form data more privately in the request body.