What are the potential benefits and drawbacks of using JavaScript or jQuery to handle page redirection based on user input in PHP?

When handling page redirection based on user input in PHP, using JavaScript or jQuery can provide a more seamless and interactive user experience. JavaScript can be used to dynamically redirect users without reloading the entire page, while jQuery can simplify the process with its built-in functions. However, relying too heavily on client-side scripting can pose security risks and may not be accessible to all users.

<?php
if(isset($_POST['submit'])){
    // Process user input here
    $redirectUrl = "new_page.php";
    echo "<script>window.location = '{$redirectUrl}';</script>";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Redirect Example</title>
</head>
<body>
    <form method="post">
        <input type="submit" name="submit" value="Submit">
    </form>
</body>
</html>