title: "Warning: Cannot modify header information - headers already sent by" error
body: <p>I keep receiving this error each time I try to submit a deletion form.</p>
  <blockquote>
  <p>Warning: Cannot modify header
  information - headers already sent by
  (output started at
  C:\xampp\htdocs\speedycms\deleteclient.php:47)
  in
  C:\xampp\htdocs\speedycms\deleteclient.php
  on line 106</p>
  </blockquote>
  <p>Is there something wrong with my code? What do I need to change to make it work?</p>
  <pre><code>&lt;?php
  if (!isset($_SESSION)) {
    session_start();
  }
  $MM_authorizedUsers = &quot;&quot;;
  $MM_donotCheckaccess = &quot;true&quot;;
  
  // *** Restrict Access To Page: Grant or deny access to this page
  function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
    // For security, start by assuming the visitor is NOT authorized. 
    $isValid = False; 
  
    // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
    // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
    if (!empty($UserName)) { 
      // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
      // Parse the strings into arrays. 
      $arrUsers = Explode(&quot;,&quot;, $strUsers); 
      $arrGroups = Explode(&quot;,&quot;, $strGroups); 
      if (in_array($UserName, $arrUsers)) { 
        $isValid = true; 
      } 
      // Or, you may restrict access to only certain users based on their username. 
      if (in_array($UserGroup, $arrGroups)) { 
        $isValid = true; 
      } 
      if (($strUsers == &quot;&quot;) &amp;&amp; true) { 
        $isValid = true; 
      } 
    } 
    return $isValid; 
  }
  
  $MM_restrictGoTo = &quot;login.php&quot;;
  if (!((isset($_SESSION['MM_Username'])) &amp;&amp; (isAuthorized(&quot;&quot;,$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
    $MM_qsChar = &quot;?&quot;;
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, &quot;?&quot;)) $MM_qsChar = &quot;&amp;&quot;;
    if (isset($QUERY_STRING) &amp;&amp; strlen($QUERY_STRING) &gt; 0) 
    $MM_referrer .= &quot;?&quot; . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . &quot;accesscheck=&quot; . urlencode($MM_referrer);
    header(&quot;Location: &quot;. $MM_restrictGoTo); 
    exit;
  }
  ?&gt;
  
  &lt;?php
      require_once('Connections/speedycms.php');
      
      $client_id = mysql_real_escape_string($_GET['id']); 
              
      $con = mysql_connect($hostname_speedycms, $username_speedycms, $password_speedycms);
  
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db(&quot;speedycms&quot;) or die(mysql_error());
  ?&gt;
  
  &lt;?php
  if (!function_exists(&quot;GetSQLValueString&quot;)) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = &quot;&quot;, $theNotDefinedValue = &quot;&quot;) 
  {
    if (PHP_VERSION &lt; 6) {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }
  
    $theValue = function_exists(&quot;mysql_real_escape_string&quot;) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  
    switch ($theType) {
      case &quot;text&quot;:
        $theValue = ($theValue != &quot;&quot;) ? &quot;'&quot; . $theValue . &quot;'&quot; : &quot;NULL&quot;;
        break;    
      case &quot;long&quot;:
      case &quot;int&quot;:
        $theValue = ($theValue != &quot;&quot;) ? intval($theValue) : &quot;NULL&quot;;
        break;
      case &quot;double&quot;:
        $theValue = ($theValue != &quot;&quot;) ? doubleval($theValue) : &quot;NULL&quot;;
        break;
      case &quot;date&quot;:
        $theValue = ($theValue != &quot;&quot;) ? &quot;'&quot; . $theValue . &quot;'&quot; : &quot;NULL&quot;;
        break;
      case &quot;defined&quot;:
        $theValue = ($theValue != &quot;&quot;) ? $theDefinedValue : $theNotDefinedValue;
        break;
    }
    return $theValue;
  }
  }
  
  if ((isset($_GET['id'])) &amp;&amp; ($_GET['id'] != &quot;&quot;) &amp;&amp; (isset($_POST['deleteForm']))) {
    $deleteSQL = sprintf(&quot;DELETE FROM tbl_accident WHERE id=%s&quot;,
                         GetSQLValueString($_GET['id'], &quot;int&quot;));
  
    mysql_select_db($database_speedycms, $speedycms);
    $Result1 = mysql_query($deleteSQL, $speedycms) or die(mysql_error());
  
    $deleteGoTo = &quot;progress.php&quot;;
    if (isset($_SERVER['QUERY_STRING'])) {
      $deleteGoTo .= (strpos($deleteGoTo, '?')) ? &quot;&amp;&quot; : &quot;?&quot;;
      $deleteGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf(&quot;Location: %s&quot;, $deleteGoTo));
  }
  
  mysql_select_db($database_speedycms, $speedycms);
  $query_delete = &quot;SELECT * FROM tbl_accident  WHERE id=$client_id&quot;;
  $delete = mysql_query($query_delete, $speedycms) or die(mysql_error());
  $row_delete = mysql_fetch_assoc($delete);
  $totalRows_delete = mysql_num_rows($delete);
  ?&gt;
  
  &lt;p class=&quot;form2&quot;&gt;Are you sure you wish to &lt;b&gt;delete&lt;/b&gt; the record for &lt;?php echo $row_delete['clientName']; ?&gt;?&lt;/p&gt;
                  &lt;form name=&quot;form&quot; method=&quot;POST&quot; action=&quot;&lt;?php echo $deleteAction; ?&gt;&quot;&gt;
              &lt;p class=&quot;form2&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Yes&quot; /&gt;
                &lt;input name=&quot;no&quot; type=&quot;button&quot; id=&quot;no&quot; value=&quot;No&quot; /&gt;
              &lt;/p&gt;
                                &lt;input type=&quot;hidden&quot; name=&quot;deleteForm&quot; value=&quot;form&quot; /&gt;
          &lt;/form&gt;     
  </code></pre>