Hi, I'm trying to add a paused re-direct to a URL using: echo '<META HTTP-EQUIV="Refresh" Content="3; URL=$mylink">'; Code (markup): But whenever I give the variable '$mylink' a value such as 'http://forums.digitalpoint.com' it won't read the value and tries to re-direct to $mylink instead. What am I doing wrong? T
Take a look here: http://ca.php.net/types.string echo "<META HTTP-EQUIV=\"Refresh\" Content=\"3; URL=$mylink\">"; PHP: echo '<META HTTP-EQUIV="Refresh" Content="3; URL=' . $mylink . '">'; PHP:
Everything is wrong in your code 1. Never use upper case letter for tags in HTML (you must write <meta instead of <META) 2. If it is refresh function, why u need enter url? Refresh means update same page, so you can leave it blank 2. Use JavaScript for page refresh, as I remember refresh by meta tag is not supported some modern browsers There is JavaScript example for page refresh: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Page Refresh</title> <script language="javascript" type="text/javascript"> <!-- function autorefresh(timeout) { setTimeout("location.reload(true);", (timeout*1000)); } //--> </script> </head> <body onload="autorefresh(5);"> Bla Bla Bla :) </body> </html> Code (markup): 5 in body tag means seconds between refresh <body onload="autorefresh(5);"> so if you change it to 10, page will be updated every 10 second.
<?php $mylink = "http://www.google.com"; echo "<META HTTP-EQUIV='Refresh' Content='3' URL='{$mylink}'>"; ?> Code (markup): or use header for instant redirect: <?php $mylink = "http://www.google.com"; header("Location:{$mylink}"); ?> Code (markup): hope it helps, gud luck
Better use PHP built-in headers for redirecting/refreshing if you're afraid some browsers may not support your code.
some hostings allow headers to be sent only once. if this is the case with ur hosting then nikolos code would be useful.