Is it possible to pass a value to the redirect page in PHP to trigger the execution of JavaScript only under certain conditions?

To pass a value to the redirect page in PHP and trigger the execution of JavaScript only under certain conditions, you can use PHP to set a session variable based on the condition. Then, on the redirect page, check the session variable and output the JavaScript code accordingly.

<?php
session_start();

// Set a session variable based on the condition
if (/* your condition here */) {
    $_SESSION['trigger_js'] = true;
}

// Redirect to the page
header('Location: redirect_page.php');
exit;
?>
```

On the redirect_page.php:

```php
<?php
session_start();

if (isset($_SESSION['trigger_js']) && $_SESSION['trigger_js']) {
    echo '<script>alert("JavaScript executed!");</script>';
    // Reset the session variable
    unset($_SESSION['trigger_js']);
}
?>