Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page redirect after certain time PHP

Tags:

redirect

php

There is a certain PHP function for redirecting after some time. I saw it somewhere but can't remember. It's like the gmail redirection after logging in. Please, could anyone remind me?

like image 540
afaolek Avatar asked May 25 '11 04:05

afaolek


People also ask

How do I automatically redirect a page after 5 seconds?

To redirect a webpage after 5 seconds, use the setInterval() method to set the time interval. Add the webpage in window. location. href object.

How do you call a PHP function after some time?

Using pcntl_alarm... Alternatively, if you have the Process Control support enabled in your build of PHP, you might be able to use pcntl_alarm to call a signal handler after a certain amount of time has elapsed.

How do I redirect after delay?

If you want to redirect a page automatically after a delay then you can use the setTimeout() method in JavaScript and it will call the above property after a time delay. The solution is very simple. The setTimeout() method will call a function or execute a piece of code after a time delay (in millisecond).

How automatically redirect to another page in PHP?

Answer: Use the PHP header() Function You can simply use the PHP header() function to redirect a user to a different page. The PHP code in the following example will redirect the user from the page in which it is placed to the URL http://www.example.com/another-page.php . You can also specify relative URLs.


2 Answers

header( "refresh:5;url=wherever.php" ); 

this is the php way to set header which will redirect you to wherever.php in 5 seconds


Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. (source php.net)

like image 184
Teneff Avatar answered Oct 15 '22 13:10

Teneff


You can use javascript to redirect after some time

setTimeout(function () {    window.location.href= 'http://www.google.com'; // the redirect goes here  },5000); // 5 seconds 
like image 37
Ibu Avatar answered Oct 15 '22 13:10

Ibu