title: Alertbox displays on seperate page rather than the same page.
body: <p>I have used a alert box where once the data is added to the database it should pop up the alert box success message on the same page, but it displays on a different blank page rather than on same page. 
  Here is my code: </p>
  
  <pre><code>&lt;?php
      require("../connect.php");
      error_reporting(0);
      /*
      if(!(adminsessioncheck()))
      header('location:index.php'); */
  
      if(isset($_POST['add']))
      {
          $username=$_POST['username'];
          $password=$_POST['password'];
  
  if($_POST['password'] !== $_POST['cpassword']) {
       echo("Password did not match! Try again. ");
  } 
  else {
      mysql_query("INSERT INTO users VALUES('','$username','$password')") or die(mysql_error());
  
      echo '&lt;script type="text/javascript"&gt; window.alert(""New user added."")&lt;/script&gt;';
  
  }
  
      }
  ?&gt;
  
  
  &lt;form action="" method="post" &gt;
       &lt;table width="330" height="135" border="0" class="text"&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;label&gt;User Name&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="username" id="username" required&gt;&lt;/td&gt; 
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;&lt;label&gt;Password&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="password" id="password" name="password" required&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;&lt;label&gt;Confirm Password&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="password" id="cpassword" name="cpassword" required&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td align="center"&gt;&lt;input type="submit" name="add" value="Add"&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
    &lt;/form&gt;
  </code></pre>