2

How do I redirect page with PHP after 5 seconds to file register.php? No Javascript or other code, just plain PHP.

Is it possible? How do I do it? I've seen Location: header.

JoquiCodee
  • 33
  • 1
  • 1
  • 4
  • Possible duplicate of [How to redirect automatically after short delay on Error 404 page?](http://stackoverflow.com/questions/18029518/how-to-redirect-automatically-after-short-delay-on-error-404-page) – Jed Fox Jan 06 '17 at 19:20

3 Answers3

9

Use header Refresh. It is simple:

header("Refresh:5; url=register.php");

It should work, make sure no output is before this header.

devondre
  • 493
  • 6
  • 14
4

You have a few options:

  1. Refresh Header

    header("Refresh:5; url=register.php");
    
  2. Sleep then Location Header

    sleep(5);
    header("Location: register.php");
    

The first option is best, the sleep in the 2nd is blocking and could be used to DDos your service.

Phil Poore
  • 2,086
  • 19
  • 30
1
// sleep php process
sleep(5);
// redirect
header("location: register.php");
harry
  • 483
  • 2
  • 12