Automatic redirect

HiSometimes it is necessary to redirect the viewer automatically to another page. This can be achieved in several ways.

None are perfect for every instance and the most important issue to bear in mind is that if your get the server to drive it - the client browser has nothing to do with it - but its use is limited to action prior to anything at all delivered to the browser. The other methods rely entirely upon the browser, and that means the client may interfere with your intended action.

  1. PHP header redirect - BUT there must be NO output to browser before this command
  2. Javascript - but viewer MUST have Javascript turned on
  3. Meta tag in header - but viewer can override this (if they know what they are doing
To deal with each in turn:
  1. PHP header redirect
    Go here to PHP manual

    $host = $_SERVER['HTTP_HOST'];
    $dir = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $sess = session_id();
    $file2go2 = "redirect.php?sess=$sess";

    header("Location: http://$host$dir/$file2go2");

    The code "http://$host$dir/$file2go2" is displayed below here - exactly as written
    http://itsveryeasy.com/redirect.php?sess=igu55gese8mhcsg2c34mulqv56

Go Home