gevo12321 Posted June 25, 2007 Share Posted June 25, 2007 you know on some websites when you go they automatically transfer you to a certain link how do they do it? Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/ Share on other sites More sharing options...
teng84 Posted June 25, 2007 Share Posted June 25, 2007 redirecting that when they header file sample header('location:then your location here') Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281758 Share on other sites More sharing options...
gevo12321 Posted June 25, 2007 Author Share Posted June 25, 2007 is it possible to redirect after a certain time period? lets say 5 sec? Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281760 Share on other sites More sharing options...
The Little Guy Posted June 25, 2007 Share Posted June 25, 2007 header("redirect: 5; http://google.com"); Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281763 Share on other sites More sharing options...
mkoga Posted June 25, 2007 Share Posted June 25, 2007 you'd have to use javascript: function gotoUrl(url) { document.location = url; } function startTimer() { setTimeout("gotoUrl('<?php echo $url; ?>')", 5000); } then just call startTimer to start the 5 sec count down. hope this helps. Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281769 Share on other sites More sharing options...
AndyB Posted June 25, 2007 Share Posted June 25, 2007 From the manual at http://ca.php.net/manual/en/function.header.php, it's Refresh not redirect I found the following code to help me refresh a page or really redirecting to a page after a certain number of secionds. (I'm using php 5.x) <?php print(" <p align=\"center\"> User Not Found</p><br><br>"); // err msg header('Refresh: 3; url=index.html'); // waits 3 seconds & sends to homepage ?> Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281770 Share on other sites More sharing options...
gevo12321 Posted June 25, 2007 Author Share Posted June 25, 2007 so... if i want to insert data into a database and after i click the submit button i want the page to say "thank you. you will be redirected back in 5 seconds" do i put the redirect after i close my mysql connection? Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281772 Share on other sites More sharing options...
AndyB Posted June 25, 2007 Share Posted June 25, 2007 you'd have to use javascript: No you don't. See my post from the manual. Also consider the standard HTML meta refresh Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281773 Share on other sites More sharing options...
AndyB Posted June 25, 2007 Share Posted June 25, 2007 so... if i want to insert data into a database and after i click the submit button i want the page to say "thank you. you will be redirected back in 5 seconds" do i put the redirect after i close my mysql connection? No, you'll get a 'headers already sent error because you've sent data to the browser. Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281774 Share on other sites More sharing options...
gevo12321 Posted June 25, 2007 Author Share Posted June 25, 2007 ok when i click the submit button, this code takes action: <?php require_once('../connect.php'); $newsnumber = $_POST[newsnumber]; $date1 = $_POST[date1]; $title = $_POST[title]; $news = $_POST[news]; mysql_query("UPDATE `news` SET `date` = '". $date1 . "', `title` = '".$title."', `news` = '".$news."' WHERE newsnumber = '" . $newsnumber . "'"); echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> <html> <body> News Archive has been edited <br> You will be redirected back to the news page in 3 seconds. <br> Thank You </body> </html> "; mysql_close($link) ?> how do i modify this code to redirect me after 3 sec? Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281777 Share on other sites More sharing options...
gevo12321 Posted June 25, 2007 Author Share Posted June 25, 2007 nvm i got it thx il just use the html meta redirect like this: <?php require_once('../connect.php'); $newsnumber = $_POST[newsnumber]; $date1 = $_POST[date1]; $title = $_POST[title]; $news = $_POST[news]; mysql_query("UPDATE `news` SET `date` = '". $date1 . "', `title` = '".$title."', `news` = '".$news."' WHERE newsnumber = '" . $newsnumber . "'"); echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> <html> <head> <meta http-equiv=\"Refresh\" content=\"2; url=enews.php\"> </head> <body> News Archive has been edited <br> You will be redirected back to the news page in 2 seconds. <br> Thank You </body> </html> "; mysql_close($link) ?> thank you Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281783 Share on other sites More sharing options...
The Little Guy Posted June 25, 2007 Share Posted June 25, 2007 From the manual at http://ca.php.net/manual/en/function.header.php, it's Refresh not redirect I found the following code to help me refresh a page or really redirecting to a page after a certain number of secionds. (I'm using php 5.x) <?php print(" <p align=\"center\"> User Not Found</p><br><br>"); // err msg header('Refresh: 3; url=index.html'); // waits 3 seconds & sends to homepage ?> Oops.. I use that function lots... I should have know that. Link to comment https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.