简体   繁体   中英

PHP Redirect for 5 seconds, then return back to originating page

I am new to PHP and have been attempting to write a simple PHP script that will is activated from a "submit" button.

  1. Show a "Welcome message"
  2. Redirect to a an external page for 5 seconds, then return to the script.
  3. Show a "Thank you"

So far I've tried:

<?php
echo 'Welcome to ......'; 
header( "refresh:5;url=what.html" ); 
?> 

Any suggestions? At the moment it justs redirects after 5 seconds, and I need to return back to a "Thank you prompt"

You can't code on same page 'source.html' to redirect on 'destination.html' for 5 minutes only.

For that you have to first redirect to 'destination.html' and there you have to add code to return back to 'source.html' page after 5 seconds.

First of all you need to send the headers before doing any output! You also may use HTML Tags to do the redirection.

<html>
    <head>
        <title>Title</title>
        <meta http-equiv="refresh" content="5; URL=/what.html">
    </head>
    <body>
        <p>Welcome to ......</p>
    </body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM