Jump to content

Archived

This topic is now archived and is closed to further replies.

PC Nerd

Php Redirecting Users

Recommended Posts

hey guys


i want to send users to another page i understand this can be done with header('location: .........'

how can i put a delay on this. eg relocate after 10 sec, so that i can display info on where the user is going before they go..


any help would be much appreciated.

Share this post


Link to post
Share on other sites


<?php

// refresh / redirect to an internal web page
// ------------------------------------------
header( 'refresh: 5; url=/webdsn/' );
echo '<h1>You will be re-directed in 5 seconds...</h1>';


// refresh / redirect to an internal web page
// ------------------------------------------
header( 'refresh: 3; url=/' ); # redirects to our homepage
echo '<h1>You will be re-directed in 3 seconds...</h1>';


// refresh / redirect to an external web page
// ------------------------------------------
header( 'refresh: 0; url=http://www.example.net' );
echo '<h1>You won\'t know what hit you!</h1>';
?>

Share this post


Link to post
Share on other sites
you could also use this. . .much smaller code, and imo a bit cleaner code

[code]header("Location: http://www.example.com");[/code]

Share this post


Link to post
Share on other sites
cool thanks

so wats the difference between location: and src = .......


Which one should i use???


Thanks again

Share this post


Link to post
Share on other sites
I use the one I pasted above. . .i assume his code works too, so it doesnt matter which one you use. . .which ever one looks better to you.

you could even do a iinie, meanie, minie, moe about it. lol

Share this post


Link to post
Share on other sites
Dville the user ask for a 10 sec delay can you exsplain how yours delays cheers........................


Dville code is for redirecting only.

the code i posted is for redirecting set via a time ok like 10 sec set via the refresh rate............

good luck.

Share this post


Link to post
Share on other sites
good point

[code]sleep(5); // wait for five seconds
header("Location: http://www.example.com"); // redirects you to example.com[/code]

im still new to this myself, but the above code works with a pause :p

Share this post


Link to post
Share on other sites
[!--quoteo(post=389115:date=Jun 29 2006, 05:08 AM:name=Dville)--][div class=\'quotetop\']QUOTE(Dville @ Jun 29 2006, 05:08 AM) [snapback]389115[/snapback][/div][div class=\'quotemain\'][!--quotec--]
good point

[code]sleep(5); // wait for five seconds
header("Location: http://www.example.com"); // redirects you to example.com[/code]

im still new to this myself, but the above code works with a pause :p
[/quote]

sleep is not part of header but corect flashee lol

Share this post


Link to post
Share on other sites
Thanks Now i want to do a login page. Once the page opens it is sent login info. From there it connects to a databse, creates cookies and then relocates. If i use the header...... will the script still run through the db connect etc.?????


thanks for your previous replys, they'r rally halping

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.