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

Forms are the bridge between the visitor and your PHP code. When a user fills in a field and submits, the data arrives on the server.

On the HTML side

  • The <form method= »post » action= »process.php »> tag defines where and how to send the data.
  • Every field has a name attribute, e.g. <input name= »firstname »>.

On the PHP side

PHP receives this data in the superglobal array $_POST. You read a field by its name: $_POST[« firstname »].

  1. Check that the field exists with isset($_POST[« firstname »]).
  2. Store the value in a variable.
  3. Use it (display it, save it and so on).

There is also $_GET, which passes data through the URL. $_POST is preferable for sensitive or large amounts of data.

Key point: every field needs a name, and PHP reads its values from $_POST. Always check it exists with isset.

Prix indicatifs, convertis depuis l'euro