How can PHP scripts be modified to verify the content of text fields, such as checking for specific domains in email addresses?

To verify the content of text fields in PHP, such as checking for specific domains in email addresses, you can use regular expressions to validate the input. By using a regular expression pattern, you can define the format that the text field should match, such as requiring a specific domain in an email address. This helps ensure that the user input meets the desired criteria before processing it further.

$email = $_POST['email'];

// Regular expression pattern to check for a specific domain in email address
$pattern = '/^[a-zA-Z0-9._%+-]+@example.com$/';

if (preg_match($pattern, $email)) {
    // Email address is valid with the specified domain
    echo "Email address is valid.";
} else {
    // Email address does not match the specified domain
    echo "Email address is not valid.";
}