Apprendre PHP (Hors-série) - Récupérer dynamiquement les valeurs d'un formulaire

15 Mar 2019 · 7 min
6:52

In this French tutorial, the presenter demonstrates how to automatically retrieve form data in PHP without manually declaring a variable for each input field. Starting from a standard HTML form that posts fields such as name, surname, email, login, and passwords, he shows the limitations of manually assigning each $POST entry to a scalar variable. He then introduces a method that extracts the keys and values of the $POST superglobal, builds parallel arrays with arraykeys and arrayvalues, and iterates over them to create dynamic variables (e.g., $nom, $prenom, $email) using variable variables. After confirming the approach works, he simplifies the code further by using a foreach loop that directly maps each key to its value. The video also illustrates how these dynamic variables can be used to repopulate form fields after validation errors, improving user experience. Finally, he mentions that the same technique applies to $_GET and suggests centralizing the routine in a single include file for reuse across multiple pages.

Chapters

More from Yamossoun

8:56
youtube.com

Compteur synchrone - Logique séquentielle

2w ago
11:58
youtube.com

Compteur asynchrone et diviseur de fréquence - Logique séquentielle

3w ago
11:37
youtube.com

Les registres (parallèle et à décalage) - Logique séquentielle

1mo ago
6:14
youtube.com

Bascule T (Toggle) - Logique séquentielle

1mo ago
12:05
youtube.com

Bascule JK - Logique séquentielle

1mo ago
9:17
youtube.com

Bascule D flip-flop active sur front montant - Logique séquentielle

1mo ago
10:08
youtube.com

Bascule D Latch - Logique séquentielle

1mo ago
8:13
youtube.com

Bascule RS - Logique séquentielle

1mo ago
5:04
youtube.com

Logique séquentielle - Introduction

2mo ago
1:15
youtube.com

Le codeur - Logique combinatoire #codeur #logique #circuit #booleanlogic

2mo ago
1:56
youtube.com

Algorithme de calcule de la racine carrée par dichotomie #dichotomy #squareroot #algorithm

3mo ago
See all content