Safe redirection


/ Published in: PHP
Save to your folder(s)

If your page has already sent headers to the browser you cant redirect with headers('Location:' . $url);

But you can use the following:


Copy this code and paste it in your HTML
  1. /**
  2. * Usage: safe_redirect('http://www.google.com');
  3. *
  4. */
  5.  
  6. function safe_redirect($url){
  7. ?><script>
  8. <!--
  9. window.location= "<? echo $url; ?>"
  10. //-->
  11. </script>
  12. <?
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.