๐Ÿ’‰
Security

SQL injection: what it is and protection

04.02.2025
โ† All articles

SQL injection โ€” injecting malicious SQL through user input. OWASP Top 10 #1.

Example

WHERE name='$name' โ€” user enters admin' OR '1'='1 โ€” logs in as admin.

Only right way: Prepared Statements

PDO: $st->prepare(...); $st->execute([$name]).

What NOT to do

String concatenation, mysql_real_escape โ€” outdated.

ORM

Eloquent, Doctrine โ€” auto prepared.

Related articles

๐Ÿ’พ Securing user data ๐Ÿ“ง SPF, DKIM, DMARC โ€” protect your email from spoofing ๐Ÿ’พ Site backups โ€” why and how ๐Ÿ›ก Site security โ€” 10 essential measures
๐ŸŒ Language
๐Ÿ‡บ๐Ÿ‡ฟ O'zbek ๐Ÿ‡บ๐Ÿ‡ฟ ะŽะทะฑะตะบ ๐Ÿ‡ท๐Ÿ‡บ ะ ัƒััะบะธะน ๐Ÿ‡ฌ๐Ÿ‡ง English โœ“