PhPHP · Lesson 7 of 8
Handling Web Requests
PHP's home turf: a form posts to your script, you read the input, talk to a database, and print HTML. Here's the raw version every framework abstracts.
⚠ Warning
Two security rules cover most PHP vulnerabilities ever written: (1) escape all output with htmlspecialchars() to stop XSS; (2) never concatenate user input into SQL — use prepared statements (PDO below) to stop SQL injection.
Two security rules cover most PHP vulnerabilities ever written: (1) escape all output with htmlspecialchars() to stop XSS; (2) never concatenate user input into SQL — use prepared statements (PDO below) to stop SQL injection.
◆ Note
Each request starts a fresh PHP process state — no memory carries over between requests. That 'shared-nothing' model is why PHP scales so simply, and why sessions ($_SESSION) exist for the state you do want to keep.
Each request starts a fresh PHP process state — no memory carries over between requests. That 'shared-nothing' model is why PHP scales so simply, and why sessions ($_SESSION) exist for the state you do want to keep.