Page 1 of 1

How to autodirect to index pg after login???

Posted: Thu Feb 23, 2012 1:16 pm
by lakc
Hey,

How can i do this...like wise as seen on this forum when u log into this forum...

1. login correctly
2. msg login sucess
3.auto redirect to index pg after couple of secs

whts the code btween step2 and 3.. i know its timer that can be done in couple of statements..how should i code it in php???

Thank you.

Re: How to autodirect to index pg after login???

Posted: Thu Feb 23, 2012 5:47 pm
by Shahlin
use the header function.
header ('Location: index.php') ;

Re: How to autodirect to index pg after login???

Posted: Thu Feb 23, 2012 11:19 pm
by jacek
Yep header() is the best way.

I you want the delay of 3 seconds, the only clean way to do it is using JavaScript.

The code would look something like this
window.onload = function(){
    setTimeout(function(){
         window.location = 'http://google.com/';
    }, 3000);
}
Excuse the use of window.onload ;)