SQL injection
An attack where database commands are typed into an input field and run because the program joins the input straight into a query. Parameterised queries stop it.
Understanding SQL injection in Years 9–10 Digital Systems
What it does: The input is joined directly into the query, which is what makes SQL injection possible. The ? placeholder sends the input separately from the SQL, so injected commands are treated as plain text. This is the fix. SQL injection tricks a program into running commands that were typed into a form. Flooding a site with traffic is a denial of service attack. '1'='1' is always true, so the check can pass without the real password. A parameterised query sends the input as data only, so it is never run as a command. Hiding the form doesn't fix the flaw. SQL injection can expose private records such as names and passwords, or delete whole tables.
Common mistakes: The attacker's input needs a condition that is always true. '1'='2' is false, so it would not expose every row. It should be '1'='1. This joins the user's input straight onto the query, which is what allows SQL injection. The input should be passed separately as a parameter: cur.execute(sql, (user,)).
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 41–69) and word search (Modules 41–79).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
SQL injectionFill in the Blanks
Spot the Error
Student with a class code? Join your class →