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.