Contenu du cours
Module 1 — Discovering PHP
Understand what PHP is, set up a local environment and write your first script.
0/4
Module 3 — Functions, arrays and forms
Create functions, work with arrays and handle data coming from a form.
0/4
PHP for beginners

Never trust data sent by a user. A form field can contain malicious code. Three reflexes cover the essentials.

1. Protecting against SQL injection

Never insert a form value straight into a query. Use prepared statements (PDO): the value is treated as plain data, never as SQL code.

2. Protecting against XSS flaws

Before displaying data that was typed in, run it through htmlspecialchars(). This turns tags into harmless text and blocks script injection.

3. Validating and filtering

  • Check the expected format (does an email actually look like an email?).
  • Use filter_var() to validate or clean up.
  • Check the length and the type of the data.

Key point: prepared statements against SQL injection, htmlspecialchars() against XSS. The golden rule: never trust user input.

Prix indicatifs, convertis depuis l'euro