1 Reply Latest reply on Oct 18, 2010 10:48 PM by w1n78

    Using Header Function

    brywilson88

      I want to create an if statement using a header.

       

      Example – If a condition is met – do the header function – else – write this html (render the page):

       

      <?php

      if ($row_test['type'] = “b”) {

                  $newsite = $row_test['site'];

      header("Location: $newsite");

      exit;

      }

      ?>

       

      <!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">

       

      Stuff goes here ....

       

      </html>

       

      I can get the first part to work – if a condition is met – the header function redirects to the page I want.

       

      But, if the condition is not met – it seems the code gets stuck in a loop then end up at my 404 page – I think it is trying to perform the header function (even though it is in an if statement and the condition is not met).

       

      What am I doing wrong?