title: Clicking on 'submit' button navigates to another page
body: <p>I am about to build a comment section in my website. I made comment box. Posting comment and updating that into database works fine. But the problem is while submitting any comment it navigates me to the first page (in my case it's home page under the HOME tab). It doesn't let user stay at the same page. </p>
  
  <p>On the other hand, posting comment functionality doesn't work at all when I simply run the PHP file in a web browser. That means running the site in my directory root (like this: file:///C:/xampp/htdocs/jquery/main.php). Why so?</p>
  
  <p>Last but not least, error messages are not shown in the page where the comment box is located, rather it prints the message in the first HOME page, at the top, above the header. For example I added a reminder ("Please fill all the fields") to user if they don't fill all the fields. This message gets printed in the starting page on my site.</p>
  
  <p>main.php:</p>
  
  <pre><code> &lt;!--php code for comment section starts--&gt; 
  
   &lt;?php
  mysql_connect("localhost","root","");
  mysql_select_db("comment_section");
  $name=isset($_POST['name'])? $_POST['name'] : '';
  $comment=isset($_POST['comment'])?$_POST['comment'] : '';
  $submit=isset($_POST['submit'])?$_POST['submit'] : '';
  
  $dbLink = mysql_connect("localhost","root","");
      mysql_query("SET character_set_client=utf8", $dbLink);
      mysql_query("SET character_set_connection=utf8", $dbLink);
  
  if($submit)
  {
  if($name&amp;&amp;$comment)
  {
  $insert=mysql_query("INSERT INTO comment (name,comment) VALUES ('$name','$comment') ");
  }
  else
  {
  echo "please fill out all fields";
  }
  }
  ?&gt;
  
  
  
  
  
  
  &lt;!--php code for comment section ends--&gt; 
   &lt;!--building a comment section starts--&gt;
  
  &lt;center&gt;
  &lt;form action="main.php" method="POST"&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;Name: &lt;br&gt;&lt;input type="text" name="name"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan="2"&gt;Comment: &lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan="5"&gt;&lt;textarea name="comment" rows="10" cols="50"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan="2"&gt;&lt;input type="submit" name="submit" value="Comment"&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;!--building a comment section ends--&gt;
  &lt;!--building a comment section's functionality starts--&gt;
  &lt;?php
  {
  $dbLink = mysql_connect("localhost","root","");
      mysql_query("SET character_set_results=utf8", $dbLink);
      mb_language('uni');
      mb_internal_encoding('UTF-8');
  
  $getquery=mysql_query("SELECT * FROM comment ORDER BY id DESC");
  while($rows=mysql_fetch_assoc($getquery))
  {
  $id=$rows['id'];
  $name=$rows['name'];
  $comment=$rows['comment'];
  
  echo $name.'&lt;br /&gt;'.'&lt;br /&gt;'.$comment .'&lt;br/&gt;'.'&lt;br/&gt;'.'&lt;hr size="1"/&gt;';}
  
  }
  
  ?&gt;
  &lt;!--building a comment section's functionality ends--&gt;
  </code></pre>