How can JavaScript be used to handle page redirection after a certain time interval when PHP is involved?
When PHP is involved, you can use JavaScript to handle page redirection after a certain time interval by embedding JavaScript code within the PHP script. You can use the `header()` function in PHP to set a refresh header that redirects the page after a specified time. By combining PHP and JavaScript, you can achieve the desired page redirection functionality.
<?php
// PHP code to redirect the page after 5 seconds
echo '<script type="text/javascript">
setTimeout(function(){
window.location.href = "new_page.php";
}, 5000);
</script>';
?>
Keywords
Related Questions
- How can one prevent the content of the previous page from being carried over when redirecting to a new page in PHP?
- What are the common mistakes when using sessions in PHP for user authentication?
- How can PHP developers ensure that each record is updated individually and not all at once with the same values?