Sanitize HTML Output
Escapes browser-facing text with `htmlspecialchars()` at render time so names, notes, and labels cannot become executable HTML.
Open SnippetPractical pure PHP patterns that are easy to study, adapt and use.
Escapes browser-facing text with `htmlspecialchars()` at render time so names, notes, and labels cannot become executable HTML.
Open SnippetSets an HTTP status code and JSON content type header before encoding an API response payload.
Open SnippetValidates a local redirect target, sends a `Location` header, and exits before any accidental output can continue.
Open SnippetStarts a PHP session only when needed, sets safer cookie options before startup, and reports the resulting session status.
Open SnippetSets one allowlisted session key, reads it back, and returns a clear status without storing credentials or raw sensitive data.
Open SnippetDestroys the active PHP session, clears the session array, and expires the session cookie for logout or reset workflows.
Open SnippetReads an allowlisted subset of `$_SERVER`, normalizes common request values, and avoids dumping sensitive server internals.
Open SnippetHandles a basic `POST` form by checking the request method, trimming fields, validating email, and returning errors or clean data.
Open SnippetInserts one mission-log row with procedural mysqli, then returns the exact auto-increment ID produced by that insert.
Open SnippetUpdates one inventory row with procedural mysqli, validates the row ID, and reports whether a row actually changed.
Open SnippetDeletes one confirmed row with procedural mysqli and returns a clear result without unsafe broad deletion.
Open SnippetRuns a targeted procedural mysqli update and returns the number of rows changed by that statement.
Open Snippet