title: Staying in same page, after inserting data in MySQL using PHP using POST method
body: <p>I'm having a simple problem, but I don't know how to overcome it.</p>
  
  <p>Here's my page with the form</p>
  
  <pre><code>&lt;div id="register"&gt;
  &lt;table border="0" cellpadding="0" cellspacing="0" align="center" width="1000px" &gt;
  &lt;tr&gt;
  &lt;td height="300px" width="300px" align="center"&gt;
  &lt;/td&gt;
  &lt;td height="300px" width="400px" align="center" background="Images/panel2.png"&gt;
  &lt;form action="reg_conn.php" method="post"&gt;
  &lt;FIELDSET&gt;
  &lt;LEGEND&gt;Register&lt;/LEGEND&gt;&lt;P&gt;
     &lt;table width="350px" cellpadding="0" cellspacing="0" border="0" align="center"&gt;
        &lt;tr&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
             &lt;label for="username" &gt;UserName:&lt;/label&gt;
        &lt;/td&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
               &lt;input type="text" name="username" class="textfield"/&gt;
        &lt;/td&gt; 
        &lt;td align="center" width="50px"/&gt;        
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td colspan="5" align="center" height="10px"/&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
             &lt;label for="name" &gt;Name:&lt;/label&gt;
        &lt;/td&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
               &lt;input type="text" name="name" class="textfield"/&gt;
        &lt;/td&gt; 
        &lt;td align="center" width="50px"/&gt;        
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td colspan="5" align="center" height="10px"/&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
             &lt;label for="email" &gt;Email:&lt;/label&gt;
        &lt;/td&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
               &lt;input type="text" name="email" class="textfield"/&gt;
        &lt;/td&gt; 
        &lt;td align="center" width="50px"/&gt;        
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td colspan="5" align="center" height="10px"/&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
             &lt;label for="password" &gt;PassWord:&lt;/label&gt;
        &lt;/td&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
               &lt;input type="password" name="password" class="textfield"/&gt;
        &lt;/td&gt; 
        &lt;td align="center" width="50px"/&gt;        
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td colspan="5" align="center" height="10px"/&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
             &lt;label for="security_q" &gt;Security Question:&lt;/label&gt;
        &lt;/td&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
                &lt;select name="security_q" class="dropdown" style="width: 100px" &gt;
                      &lt;option value="My 1st Teacher"&gt;My 1st Teacher&lt;/option&gt;
                      &lt;option value="My 1st Pet"&gt;My 1st Teacher&lt;/option&gt;
                      &lt;option value="My 1st Crush"&gt;My 1st Crush&lt;/option&gt;
                &lt;/select&gt;     
        &lt;/td&gt; 
        &lt;td align="center" width="50px"/&gt;        
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td colspan="5" align="center" height="10px"/&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
             &lt;label for="security_a" &gt;Security Answer:&lt;/label&gt;
        &lt;/td&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="100px"&gt;
              &lt;input type="text" name="security_a" class="textfield"/&gt;
        &lt;/td&gt; 
        &lt;td align="center" width="50px"/&gt;        
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td colspan="5" align="center" height="10px"/&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;td align="center" width="250px" colspan="3"&gt;
             &lt;input type="submit" class="button" style="width: 200px; height: 20px;" /&gt;
        &lt;/td&gt;
        &lt;td align="center" width="50px"/&gt;
        &lt;/tr&gt; 
      &lt;/table&gt;    
  &lt;/FIELDSET&gt;
  &lt;/form&gt;
  &lt;/td&gt;
  &lt;td height="300px" width="300px" align="center"/&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And my reg_conn.php file is as follows:</p>
  
  <pre><code>&lt;?php
  include('connection.php');
  $sql="INSERT INTO candidate_register_table (username, name, email, password, security_q, security_a)
  VALUES
  ('$_POST[username]','$_POST[name]','$_POST[email]','$_POST[password]','$_POST[security_q]','$_POST[security_a]')";
  
  if (!mysql_query($sql,$con))
    {
    die('Error: ' . mysql_error());
    }
  mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p>Now when I submit, the page is redirected to the reg_conn.php file. I don't want that; I want to stay on the previous page. How can this be done?</p>