- The client (browser, phone app) asks for something. The server (a program on a remote computer) answers.
- Communication uses HTTP/HTTPS (HyperText Transfer Protocol; the S means encrypted with TLS).
- Static page: the server sends a stored
.htmlfile unchanged. Everyone sees the same content. - Dynamic page: the server runs a program that builds the HTML for each request (using form data, the database, the logged-in user). Different users see different content.
- Front-end = what runs in the browser (HTML, CSS, JavaScript). Back-end = what runs on the server (PHP, database). Never put secrets (database passwords) in front-end code, because users can read it.
An HTTP request contains a method (GET, POST...), a URL, headers (e.g. Cookie, Content-Type) and optionally a body. A response contains a status code, headers and a body.
| Status | Meaning |
|---|---|
| 200 | OK |
| 301 / 302 | Redirect (moved permanently / temporarily) |
| 400 | Bad request |
| 401 / 403 | Not logged in / not allowed |
| 404 | Not found |
| 500 | Server error (bug in your PHP code) |
See it live: open Chrome DevTools, Network tab, reload a page, click a request.