Posted By

chopbust on 03/02/11


Versions (?)

Redirect a page using Javascript through PHP

 / Published in: PHP

Redirect page using PHP function.

I don't like using header() as I like to redirect page mid-page. This is implemented using Javascript written through PHP function. Has a die() function at the end for people who has disabled their Javascript in their browser.

  1. function redirect($new_location){
  2. echo ("<script type='text/javascript'>
  3. document.location.replace('$new_location');
  4. </script> ");
  5. die();
  6. }

Report this snippet  

You need to login to post a comment.