Cheat Sheets & Quick References

HTML Forms and PHP Superglobals Cheat Sheet

Understand how PHP receives form data through superglobals and how to validate and process requests safely.

Overview

PHP exposes request information through superglobal arrays such as $_GET, $_POST, $_FILES, $_COOKIE and $_SERVER. These values originate outside the application's trust boundary.

Request handling

Use the request method and expected content type to determine how data should be read. Validate required fields, lengths, formats and allowed values on the server. Treat hidden fields and browser validation as user-controlled, not as security controls.

File uploads

Check upload error codes, size limits and detected file types. Generate safe filenames, store files outside executable public paths where possible and apply access controls.

Output and state

Escape values for their output context, protect state-changing requests with CSRF defenses and use secure cookie settings for sessions.

Official resource

PHP Variables from External Sources