title: in php, why input form when submit it takes 2 times pressed
body: <pre><code>    &lt;?php
          if ($_POST['submit']) {
              mysql_connect ("localhost", "root", "swt") or die ('Error: ' . mysql_error());
              mysql_select_db("db") or die ('Data error:' . mysql_error());
              $text = mysql_real_escape_string($_POST['comments']); 
              $query="INSERT INTO greetings (msg) VALUES ('$text')";
              mysql_query($query) or die ('Error updating database' . mysql_error());
              $id= mysql_insert_id();
              $url = "preview.php?id=".$id;
          }
      ?&gt;
  &lt;form method="post" action="&lt;? echo $url ?&gt;" enctype="multipart/form-data" &gt;
      &lt;textarea name="comments" placeholder="please input your message"&gt;&lt;/textarea&gt;
      &lt;input name="submit" type="submit" value="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>hello, sorry im newbie in PHP.
  i want to ask, why when i submit  it must takes 2 times pressed before go to the preview.php</p>
  
  <p>thanks.</p>