Redirect a page to another page for 5 seconds, and then redirect

I am trying to redirect a page to another page and is working successfully. However, I am trying to redirect the first page to another page with advertisements. This page will then be redirected to another page in five seconds.

I am trying to do this by doing the following:

<?php include('ads.php'); ?> <?php sleep(2); $url = $_GET['url']; header("Location: ".$url.""); exit; ?> 

However, it shows the ad in ads.php perfectly, but it doesn’t redirect after five seconds. I get 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 redirect to would be the following:

http://domain.com/adverts/index.php/?url=http%3A%2F%2Fitunes.apple.com%2Fmx%2Falbum%2Fstill-got-the-blues%2Fid14135178%3Fi%3D14135158

+7
source share
4 answers

on the first page (before advertising) before the doctype or html tag:

 <?php header("location: adlocationhere.php"); ?> 

Then on the announcement page put the following:

 <?php header("refresh:5;url=secondredirectafter5seconds.php"); ?> 

This will immediately redirect the first page and redirect the second page after 5 seconds. Hope this helps (it should also get rid of the ability to change header information if you put it before the doctype and html tags).

EDIT: Also, with javascript, this could be a security risk b / c, any user can change their location. By doing this in this way, you have full control over where the user is going.

+5
source

Use update meta tag or javascript window.location

+2
source

It can help you.

 setTimeout("javascript window.location",3000) 

with considering

Wazzy

+1
source

All pages have headings and content. To redirect a visitor to another page, you must do this in the page header section. After you printed the page content (your ads), you actually started the content, in which there is no need to change the headings.

The best way to do this is to have javascript like

 <script> function redirect() { window.location = '$url'; } setTimeout("redirect();", 5000); </script> 
0
source

All Articles