PHP/HTML – Redirect URL in Seconds

HTML
Use the following meta inside <head> to make URL redirection after seconds.

<head>
        <meta http-equiv="refresh" content="5; URL=http://ykyuen.wordpress.com">
</head>

You will be redirect to this blog after 5 seconds. =P

PHP
You can also make it in PHP.

<?php
        header("refresh: 5; http://ykyuen.wordpress.com");
        echo "You will be redirect in 5 seconds";
?>

Done =)

Reference: Auto Redirect after 5 Seconds..

About these ads

3 thoughts on “PHP/HTML – Redirect URL in Seconds

  1. Pingback: Javascript – HTML Redirect | Eureka!

  2. Cass

    Hmm would you by chance know how to redirect after x seconds only if not logged on. i.e if the person is logged in then the redirect does not execute? I basically am trying to figure out how to allow a person access to a page for 30 sec and then to redirect them to logged/register page and the redirect again to that initial page.

    Like

    Reply
    1. ykyuen Post author

      Sure. you should be able to check if a user has logged in or not in PHP, it depends on your authentication design. Use a if block and wrap that redirection logic with ob_start() and ob_end_flush() functions. For more information about the ob_start() and ob_end_flush(), you can refer to PHP – Redirect URL After Form Submission

      Like

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s