I am trying to redirect a page to another page and that was working successfully. However I am trying to redirect the first page to another page with adverts. This page will then redirect to another page after five seconds.
I am trying to do that by doing this:
<?php
include('ads.php');
?>
<?php
sleep(2);
$url = $_GET['url'];
header("Location: ".$url."");
exit;
?>
However it is showing the advert in ads.php
perfectly, but it is not redirecting after five seconds. I am receiving this error in my web browser:
Warning: Cannot modify header information - headers already sent by
(output started at /home/nucleusi/public_html/adverts/ads.php:1)
in /home/nucleusi/public_html/adverts/index.php on line 7
A typical link I would be redirecting to would be this:
http://domain.com/adverts/index.php/?url=http%3A%2F%2Fitunes.apple.com%2Fmx%2Falbum%2Fstill-got-the-blues%2Fid14135178%3Fi%3D14135158
on the first page(before the ads) before the doctype or html tags put:
<?php header("location: adlocationhere.php"); ?>
Then on the ad page put this:
<?php header("refresh:5;url=secondredirectafter5seconds.php"); ?>
This will redirect your first page immediately and it will redirect your second page after 5 seconds. Hope this helps (its should also get rid of the cannot modify header info if you put it before the doctype and html tags).
EDIT: Also having javascript do it can be a security risk b/c any user can change its location. By doing it this way you have full control over where the user is being directed.
Use refresh meta tag or javascript window.location
This might help you
setTimeout("javascript window.location",3000)
with regards
Wazzy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With