Validate input on the server

Treat every request parameter as untrusted. Validate types, lengths, formats, and allowed values.

Use prepared statements

Use PDO prepared statements or framework query builders instead of concatenating untrusted input into SQL.

Escape output by context

HTML-escape values before inserting them into HTML; other contexts require different handling.

Store passwords safely

Use password_hash and password_verify instead of plaintext or custom hashing.

Further reading

This guide is educational. Check current documentation before making technical or purchasing decisions.