The web

The request and the response: form input, headers and status codes, cookies, sessions and a login, a JSON endpoint, PDO and file uploads with .htaccess rewrite rules.

6.1 Forms: GET and POST read GET and POST input and validate it safely Open 6.2 HTTP: headers and status codes send a header, set a status code, and redirect correctly Open 6.3 Cookies set, read and delete a cookie safely Open 6.4 Sessions session_start and $_SESSION, and the login state they keep Open 6.5 Login with sessions password_hash and password_verify on login, and pages guarded by a session Open 6.6 JSON REST endpoint a one-file endpoint that reads php://input and answers with JSON Open 6.7 Database with PDO PDO connect, SELECT and INSERT with placeholders, no injection by construction Open 6.8 Uploads and .htaccess uploads through the FILES array and clean URLs from rewrite rules Open

Lessons