I already have a script that does this (I can just give it to you).
It is NOT a PHP script (PHP will not work in this case because PHP is executed on the server, so it cannot redirect a user after the user sees a webpage, it only does pre-render redirects). The script uses simple HTML + Javascript
However, if you want it to be in PHP, then we can talk about the exact details of what you want to accomplish (although that doesn't make much sense for what you are explaining).