Jump to content

How To Redirect To Another Page In 5 Seconds


hunglduc

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...