What role does PHP play in handling form submissions with multiple input options like email or phone number?

When handling form submissions with multiple input options like email or phone number, PHP can be used to validate and process the data entered by the user. This can be done by checking if the input fields are empty or if they match the required format for email or phone numbers. PHP can then store the submitted data in variables or a database for further processing.

$email = $_POST['email'];
$phone = $_POST['phone'];

if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
    // Email is valid, process it further
} else {
    // Handle invalid email input
}

if (!empty($phone) && preg_match("/^[0-9]{10}$/", $phone)) {
    // Phone number is valid, process it further
} else {
    // Handle invalid phone number input
}