Recall & Review
beginner
What is input validation?
Input validation is the process of checking if the data entered by a user meets certain rules before using it. It ensures the data is correct and safe to use.
Click to reveal answer
beginner
What does input sanitization mean?
Input sanitization means cleaning or changing user data to remove harmful parts, like special characters, to make it safe for use.
Click to reveal answer
intermediate
Why do we need both validation and sanitization?
Validation checks if data is correct and fits rules. Sanitization cleans data to prevent security problems. Using both helps keep programs safe and working well.
Click to reveal answer
intermediate
Example: What happens if you validate but don't sanitize user input?
If you only validate, bad characters might still be in the input. This can cause security issues like code injection or broken pages.
Click to reveal answer
beginner
In PHP, which function is used for sanitizing email input?
The PHP function
filter_var($email, FILTER_SANITIZE_EMAIL) removes unwanted characters from an email address.Click to reveal answer
What is the main goal of input validation?
✗ Incorrect
Input validation ensures the data entered fits expected rules before using it.
Which PHP function is used to sanitize a string by removing HTML tags?
✗ Incorrect
strip_tags() removes HTML and PHP tags from a string, sanitizing it.
What can happen if you skip sanitization but validate input?
✗ Incorrect
Without sanitization, harmful characters can cause security problems even if data is valid.
Which is true about input sanitization?
✗ Incorrect
Sanitization cleans input data to remove or escape harmful parts.
Which PHP filter validates an email address?
✗ Incorrect
FILTER_VALIDATE_EMAIL checks if the input is a valid email format.
Explain the difference between input validation and input sanitization.
Think about checking vs cleaning user data.
You got /3 concepts.
Why is it important to use both validation and sanitization when handling user input in PHP?
Consider safety and correctness.
You got /3 concepts.