1000-ft view: these examples show what NOT to do — string concatenation into SQL,
trusting stored fields later (“second-order” injection), and rendering user content without encoding.
Try classic payloads like ' OR '1'='1' --, %25%27%20UNION%20SELECT…,
or <script>alert(1)</script> to see the risks.
Compare with the Secure version.
Vulnerable idea: build the query with user input:
WHERE email='$e' AND password_hash='$p'. A payload like
email = ' OR '1'='1'-- can bypass authentication.
' OR '1'='1'-- (note the space after --).
Vulnerable idea: interpolate $q into a LIKE and allow shape-compatible
UNION SELECT to exfiltrate other tables (e.g., users).
%' UNION SELECT id,email,0 FROM a03_users -- (dont forget your space)
Vulnerable idea: treat id as a free-form string and concatenate it directly.
Attackers can flip logic (boolean-based) or attempt heavy expressions to infer truth via timing.
1 OR 1=1.Vulnerable idea: accept and store a profile bio without validation, then later build a query using that stored field (e.g., to filter or join).
Vulnerable idea: render user input directly without encoding. This embedded page runs in RAW mode to demonstrate how scripts execute.
<script>alert('stored')</script>.<img src=x onerror=alert(1)>.