How to autodirect to index pg after login???

Ask about a PHP problem here.
Post Reply
lakc
Posts: 32
Joined: Fri Oct 21, 2011 6:05 pm

How to autodirect to index pg after login???

Post 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.
Shahlin
Posts: 49
Joined: Sat Jan 14, 2012 10:35 am

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

Post by Shahlin »

use the header function.
header ('Location: index.php') ;
Just A PHP Beginner!
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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 ;)
Image
Post Reply