Input validation

Input validation checks that the data received from a user has the expected shape: presence, type, length, format. In PHP, filter_var with filters such as FILTER_VALIDATE_EMAIL helps. Server-side validation is essential because the browser's can be bypassed.

Example

$email = filter_var($_POST['email'] ?? '', FILTER_VALIDATE_EMAIL);

Related concepts

The whole glossary