I have an issue using my php code within the javascript function setTimeout. The code is in a php file, but instead of acting like it should and waiting the five minutes to send the user to the index page of my website, it just does it instantly. Any ideas?
Here’s the code:
<script>
setTimeout(function() { <?php header( 'Location: /index.html' ); ?> }, 300000);
</script>
Yes. It is because the PHP Code first gets executed, because it is server-side. So you would have to modify your code: