登録が成功した後にページをリダイレクトすると、コードはすべて正常に機能しますが、ヘッダー機能が機能せず、ページがリダイレクトされません。ページはリダイレクトされません。私のコードは以下のとおりです
  <?php
error_reporting(E_ALL ^ E_NOTICE);
error_reporting(E_ALL ^ E_WARNING);
//include("lib/local_config.php");
include("lib/config.php");
$activation=md5(uniqid(rand(), true));
if(isset($_POST["tb_submit"]))
{
    $fname=$_POST["tb_fname"];
    $email=$_POST["tb_email"];
    $pass=$_POST["tb_pass"];
    $repass=$_POST["tb_repass"];
    $contact=$_POST["tb_contact"];
    $select_email=mysql_query("select email from user_reg where email='$email'");
    $rows=mysql_fetch_row($select_email);
    $e_id=$rows[0];
    if(!$email==$e_id && $pass==$repass)
    {
        $insert="insert into user_reg ( fname ,email ,password ,contact,Activation)    values      ('$fname' , '$email' , '$pass' ,'$contact' ,'$activation')";
        $insert_query=mysql_query($insert);
        if(mysql_affected_rows($connect) == 1)
        //if(mysql_affected_rows() == 1)
        {
            $to = $_POST['tb_email'];
            $subject = "Fundu App Creator - Registration confirmation mail ";
            $message = <<<DEMO
                      <html>
                      <head>
                      <link href='http://www.fundumobi.com/app/templatemo_style.css' type='text/css'  
                       rel='stylesheet' />
                     <link href='http://www.fundumobi.com/app/styles/frm.css' rel='stylesheet' 
                       type='text/css' />
                     <style type='text/css'>
                     .style1 {
                    font-size: 14px;
                    font-style: italic;
                    font-weight: bold;
                      }
                      .style2 {color: #FFFFFF}
                       </style>
                      </head>
                     <body>
                     <table width='50%' border='0' align='center'>
                     <tr>
                      <th height='100' bgcolor='#006784'>
                      <div id='site_logo'></div>    </th>
                     </tr>
                    <tr>
                    <td height='247'><div >
                      <div align='center' class='style1'>
                        <p>Your Registration is successful !!!! </p>
                        <p>Now Please click the following Button to complete the registration process:</p>
                        <p> </p><br/>
                        <div ><a href='http://www.fundumobi.com/app/activation.php?act=$activation'>      
                       <img src='images/button66535179.png'/></a></div>
                      </div></td>
                     </tr>
                     <tr>
                       <td height='64' bgcolor='#006784'><div 
                      align='center'>www.funduappcreator.com</div>    </td>
                     </tr>
                    </table>
                    </body>
                    </html>
                    DEMO;
            $from = "contact@fundumobi.com";
            mail($to, $subject, $message, 'From:'.$from);
            header("location:mesg.php");
        }
        else
        { // If it did not run OK.
            header("location:index.php?er=2");
        }
    }
}
?>