How PHP Handles Form Data | $_GET vs $_POST Explained
Category: Php
PHP handles form data using two main superglobal arrays: $_GET and $_POST.
-
$_GET collects data sent via the URL (query string). It's ideal for search forms or data that can be visible in the browser address bar.
-
$_POST collects data sent through an HTTP POST request. It’s more secure and is commonly used for login forms, contact forms, and sensitive or large amounts of data.
🧠 Example:
// Access form data
$name = $_POST['name']; // From a form with method="post"
$search = $_GET['q']; // From a form with method="get"