Jump to content

How To Redirect To Another Page In 5 Seconds


hunglduc
 Share

Recommended Posts

What was the error?Are Headers already sent?
i think its when you put that after you sent html to the page like this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <title></title>    </head>    <body>        <?php        header("Location:http://www.google.com");        ?>    </body></html>

try putting in before html that normally works like this

        <?php        header("Location:http://www.google.com");        ?>        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <title></title>    </head>    <body>    </body></html>

if your getting the Headers already sent error

Link to comment
Share on other sites

What was the error?Are Headers already sent?
when i run these code, it appeared errorWarning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/redirect.php:8) in /opt/lampp/htdocs/redirect.php on line 10
<html><head><!--<meta http-equiv="refresh" content="5;url=http://www.google.com">--></head><body><?php//echo "<meta http-equiv='refresh' content='5;url=http://www.google.com'>";	header("Location:http://www.google.com");?></body></html>

Link to comment
Share on other sites

You can have NO output to the Browser before sending a header. Not even a blank space character. Otherwise you receive a "Headers already sent error", just like above. You will need to place the header above the HTML as suggested above. All the html tags in your sample is causing the error. See the sample above yours by TKW22.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...