Superglobals are built-in variables that are always accessible, regardless of scope. Common superglobals include $_GET, $_POST, $_SESSION, and $_SERVER.
$_GET$_GET is used to collect data sent via the URL query string:
<?php
// Example: index.php?name=John
echo $_GET["name"]; // Outputs John
?>
$_POST$_POST is used to collect data sent via the HTTP POST method:
<form method="post">
Name: <input type="text" name="name">
<input type="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo $_POST["name"];
}
?>
Create a form that collects a user's email address using $_POST and displays it on the same page.
$_GET and $_POST?