Friday, 4 October 2013

Fatal error: Call to undefined function http_redirect() : Fixed

Issue: When I was trying to call the PHP http_redirect() function, below error came up:

Fatal error: Call to undefined function http_redirect() in location.

Add the below function in your php page

 * redirect to a specific URL
 * @param $url
function redirect($url)
     if (!
//If headers not sent yet... then do php redirect
header('Location: '.$url); exit;
//If headers are sent... do javascript redirect...
          //if javascript disabled, do html redirect.
echo '<script type="text/javascript">';
'<meta http-equiv="refresh" content="0;url='.$url.'" />';
'</noscript>'; exit;

then call the above function  to the page you wish the redirect to happen on

eg: redirect("redirect.php");

No comments:

Post a Comment