Level 2 exam — harder

Exam — fresh questions

2.1 · Recall

1. What do $_GET and $_POST hold?

GET: data in the URL; POST: data in the body — read via the superglobals.
2.1 · Application

2. Riad displays the name entered in his form. Which line is safe?

htmlspecialchars neutralizes injected HTML/JavaScript: the output stays text.
2.1 · Arbitration

3. A colleague claims his JavaScript validation is enough and wants to drop the PHP checks. Riad's verdict?

Disabled JavaScript, edited code or forged request: the client never protects.
2.2 · Recall

4. What is the difference between a cookie and a session?

Trusted data in sessions (server); non-sensitive preferences in cookies.
2.2 · Application

5. Riad codes the member login. Which sequence is correct?

Checked against the hash, regenerated ID against fixation, identity on the server.
2.2 · Arbitration

6. A member changes the id in the URL and sees another person's data. Which rule was missing?

Logged in does not mean authorized: each resource controls its access.
2.3 · Application

7. Riad factors his menu duplicated across ten pages. What does he do?

Write once, include everywhere: one change in a single place.
2.3 · Application

8. Riad receives an event photo via $_FILES. Which practice is correct?

Upload = hostile input: real type, renaming, storage with no execution.
2.3 · Arbitration

9. A colleague suggests include $_GET['page'] to load pages dynamically. Verdict?

A user path included without checks lets the attacker load arbitrary files.
2.4 · Recall

10. How do I correctly store and display a date?

ISO: sortable, unambiguous, the database standard; the local format is only display.
2.4 · Application

11. Riad must validate a new member's email. What does he pick?

Common case = proven filter; regex reserved for specific business patterns.
2.4 · Application

12. The newsletter must go out to 500 members. Which solution?

Dedicated library: authentication, attachments, deliverability — locked headers.
What's next?
Back to the guideGuide contents