How can PHP be used to validate form input fields for specific criteria, such as allowing only numbers 0-9?

To validate form input fields for specific criteria, such as allowing only numbers 0-9, you can use PHP's built-in functions like is_numeric() or regular expressions. You can check each input field individually to ensure it only contains numeric characters within the desired range. If the input does not meet the criteria, you can display an error message to the user.

// Example code to validate a form input field for numbers 0-9
$input = $_POST['input_field'];

if (!preg_match('/^[0-9]+$/', $input)) {
    echo "Error: Input must contain only numbers 0-9.";
} else {
    // Input is valid, continue processing
}