How can PHP be used to redirect to different URLs based on specific password inputs?

To redirect to different URLs based on specific password inputs in PHP, you can use conditional statements to check the password input and then use the header() function to redirect the user to the desired URL.

<?php
$password = $_POST['password'];

if($password == 'password1'){
    header('Location: http://example.com/page1');
    exit();
} elseif($password == 'password2'){
    header('Location: http://example.com/page2');
    exit();
} else {
    header('Location: http://example.com/invalid-password');
    exit();
}
?>