* refactor: clean to roadmap content * refactor: move shared helpers into scripts/lib
16 lines
779 B
Markdown
16 lines
779 B
Markdown
# Input Validation
|
|
|
|
Input validation is a vital aspect of PHP security. It involves checking whether the user-provided data is in the expected format or not before it's processed further. This helps prevent potential security risks such as SQL injections, cross-site scripting (XSS) etc. Let's take an example of a simple form input validation:
|
|
|
|
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
echo("Email is valid");
|
|
} else {
|
|
echo("Email is not valid");
|
|
}
|
|
|
|
|
|
This code uses PHP's built-in `filter_var()` function to ensure the data is a valid email address. If not, the form will not be submitted until valid data is entered.
|
|
|
|
Visit the following resources to learn more:
|
|
|
|
- [@official@Input Validation](https://www.php.net/manual/en/book.filter.php) |