title: PHP Header Location Not Working
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8028957/headers-already-sent-by-php">Headers already sent by PHP</a>  </p>
  </blockquote>
  
  
  
  <p>Here is my current script. Instead of redirecting like I would like it to, the page just refreshes to the current page. The page used to work, but stopped working recently for no reason. I'm on PHP 5.3</p>
  
  <pre><code>&lt;?php
  $page = "Edit Topic";
  require('top.php');
  $var = safe($_GET['id']);
  $q = mysql_query("SELECT * FROM `topics` WHERE `id`='".$var."'");
  $r = mysql_fetch_array($q);
  $c = mysql_num_rows($q);
  $user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$_SESSION['id']."'"));
  
  if($c==0) {
       echo "&lt;p&gt;This topic does not exist.&lt;/p&gt;";
  } elseif($_SESSION['name'] != $r['poster'] &amp;&amp; $user['rank'] == "Member") {
       echo "&lt;p&gt;This is not your topic.&lt;/p&gt;";
  } else {
       if(isset($_POST['enter'])) {
            $title = safe($_POST['title']);
            $post = safe($_POST['post']);
  
            if($post=='' || $title=='') {
                 $message = "You have to write something in your title and post.";
            } else {
                 mysql_query("UPDATE `topics` SET `text`='".$post."' WHERE `id`='".$r['id']."'");
                 mysql_query("UPDATE `topics` SET `title`='".$title."' WHERE `id`='".$r['id']."'");
                 header("Location: http://www.domain.com/view-post/".$r['id']."");
            }
       }
  }
  ?&gt;
  </code></pre>