title: header location not working in my php code
body: <p>i have this code,why my header location not working?
  its a form of updating and editing and deleting some pages in my control panel...and i have an index.php file in the same folder of form.php...any help please?()i tryed to put the header after the editing and deleting...and still go to the form page not the index...</p>
  
  <pre><code>&lt;?php
  include "../../includes/site_includes.php";
  //send
  if ((isset($_POST["send"])) &amp;&amp; ($_POST["send"] == 1)) {
      $pageid = $_POST["page_id"];
      $pagetitle = $_POST["page_title"];
      $nameinmenu = $_POST["page_menu_name"];
      $nameinurl = $_POST["page_name_url"];
      $link = $_POST["page_link"];
      $picture = $_POST["page_pic"];
      $desc = $_POST["page_desc"];
      $content = $_POST["page_content"];
  }
  if ((isset($_POST["act"])) &amp;&amp; ($_POST["act"] == "add")) {
      $sql = insertpage();
      if ($result = $mysqli-&gt;prepare($sql)) {
          $result-&gt;bind_param("sssssss", $pagetitle, $nameinmenu, $nameinurl, $link, $picture, $desc, $content);
          $result-&gt;execute();
          $result-&gt;store_result();
          $rows = $result-&gt;num_rows;
      }
  }
  ////edit
  if ((isset($_GET["act"])) &amp;&amp; ($_GET["act"] == "edit")) {
      $sql = getfrompages();
      if ($result = $mysqli-&gt;prepare($sql)) {
          $rekza = $_GET["id"];
          $result-&gt;bind_param("i", $rekza);
          $result-&gt;execute();
          $result-&gt;store_result();
          $rowsZ = $result-&gt;num_rows;
      }
      if ($rowsZ &gt; 0) {
          $row = fetch($result);
          $pageid = $row[0]["page_id"];
          $pagetitle = $row[0]["page_title"];
          $nameinmenu = $row[0]["page_menu_name"];
          $nameinurl = $row[0]["page_name_url"];
          $link = $row[0]["page_link"];
          $picture = $row[0]["page_pic"];
          $desc = $row[0]["page_desc"];
          $content = $row[0]["page_content"];
      }
  }
  if ((isset($_GET["act"])) &amp;&amp; ($_GET["act"] == "delete")) {
      $thedelid = $_GET["id"];
      $sql2 = delpage();
      if ($result2 = $mysqli-&gt;prepare($sql2)) {
          $result2-&gt;bind_param("i", $thedelid);
          $result2-&gt;execute();
          $result2-&gt;store_result();
          $rowsZ2 = $result2-&gt;num_rows;
      }
  }
  header('location: index.php');
  exit();
  ?&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
   &lt;head&gt;
    &lt;title&gt; pages add &lt;/title&gt;
    &lt;meta name="Generator" content="EditPlus"&gt;
    &lt;meta name="Author" content=""&gt;
    &lt;meta name="Keywords" content=""&gt;
    &lt;meta name="Description" content=""&gt;
   &lt;/head&gt;
  
   &lt;body&gt;
  &lt;form method="post" action=""&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td style="font-weight:bold;"&gt;title&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="page_title" value="&lt;?=$pagetitle?&gt;" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td style="font-weight:bold;"&gt;name in menu&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="page_menu_name" value="&lt;?=$nameinmenu?&gt;" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td style="font-weight:bold;"&gt;name in url&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="page_name_url" value="&lt;?=$nameinurl?&gt;" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td style="font-weight:bold;"&gt;link&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="page_link" value="&lt;?=$link?&gt;" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td style="font-weight:bold;"&gt;picture&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="page_pic" value="&lt;?=$picture?&gt;" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td style="font-weight:bold;"&gt;description&lt;/td&gt;
                  &lt;td&gt;&lt;textarea name="page_desc"&gt;&lt;?=$desc?&gt;&lt;/textarea&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td style="font-weight:bold;"&gt;content&lt;/td&gt;
                  &lt;td&gt;&lt;textarea name="page_content"&gt;&lt;?=$content?&gt;&lt;/textarea&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;
                  &lt;input type="hidden" name="send" value="1" /&gt;
                  &lt;input type="hidden" name="act" value="&lt;?=$_GET["act"]?&gt;" /&gt;
                  &lt;input type="hidden" name="page_id" value="&lt;?=$pageid?&gt;" /&gt;
                  &lt;input type="submit" value="add" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  &lt;/form&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>solved:</strong>
  with @ Mihai Iorga code i added ob_start();</p>