The Add Term code
Answers are for parents and teachers.
1
Write the PHP condition that is true only when $term, $trans and $defe are all non-empty after trim.
trim($term) !== '' && trim($trans) !== '' && trim($defe) !== ''
2
What do these give? (a) basename("pic/cat.webp") (b) empty("0") (c) $x ?? "none" when $x was never set
(a) cat.webp; (b) true; (c) none.
3
A term is “don’t stop”. Explain why gluing it into an INSERT breaks the command and how a prepared statement avoids this.
The apostrophe ends the quoted text early. A prepared statement sends the text separately from the command, so the apostrophe is just a character.
4
Give three reasons why the Add Term page needs the precise code and not only the short code.
The folder may not exist; empty fields would save an empty record; the visitor would get no message (also: unsafe file names and glued SQL).
5
After a save, which two things should you look at: the visitor’s message and what else?
The table in the database’s management page, to see that the record is really there.