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? Quote Link to comment 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') Quote Link to comment 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? Quote Link to comment 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"); Quote Link to comment 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. Quote Link to comment 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 ?> Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.