URL Parameters Demo

How URL Parameters Work

URL parameters (also called query strings) pass data directly in the URL after a ? character:

https://example.com/search?query=hello&page=2

The format is key=value pairs separated by &.

Key characteristics:

Try It: Sign Up Form

This form uses method="GET", which appends the data to the URL. Watch the address bar after you submit!

What You'll See

After submitting, your URL will look something like:

result.php?firstName=Alice&lastName=Smith&email=alice%40example.com&size=M

Notice that @ becomes %40 - this is URL encoding for special characters.

Security Warning: Never put sensitive data (passwords, credit cards, tokens) in URL parameters! They are:

Good Uses for URL Parameters

Accessing URL Parameters in PHP

<?php
// URL: result.php?firstName=Alice&lastName=Smith

// Access via $_GET superglobal array
$firstName = $_GET['firstName'] ?? '';  // 'Alice'
$lastName = $_GET['lastName'] ?? '';    // 'Smith'

// Always sanitize before outputting!
echo htmlspecialchars($firstName);
?>

Back to State Management | Next: Cookies Demo