title: How to prevent a php script form changing to another page
body: <p>I used a sample I found here with a HTML page calling a PHP script, both are listed below. 
  It all works well - BUT, I end up with the PHP scrip page and I want to avoid it - I want to stay on the HTML page and NOT move anywhere. I read in some places that I will need JS or AJAX but can't see any actual example.</p>
  
  <p>I am working on my PC under Windows 7 with IIS version 7.5 installed, PHP 5.3.28.
  and executing the HTML file inside c:\inetpub.wwwroot</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div id="contact"&gt;
     &lt;h2&gt;Enter your First and Last Name&lt;/h2&gt;
  
     &lt;form action="frm_script.php" method="post" target="_parent"&gt;
     &lt;p&gt;&lt;strong&gt;First Name:&lt;/strong&gt;&lt;br /&gt; &lt;input type="text" name="firstName" /&gt;&lt;/p&gt;
     &lt;p&gt;&lt;strong&gt;Last Name:&lt;/strong&gt;&lt;br /&gt; &lt;input type="text" name="lastName"/&gt;&lt;/p&gt;
     &lt;input type="submit" name="submit" value="Add Customer" /&gt;
     &lt;/form&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>PHP Script</strong></p>
  
  <pre><code>&lt;?php
  if(isset($_POST['submit']))
  {
      //get the name and comment entered by user
      $firstName = $_POST['firstName'];
      $lastName = $_POST['lastName'];
  
      //connect to the database
      $dbc = mysqli_connect('localhost', 'root', 'root', 'mdpdata') or die('Error connecting to 
      MySQL server');
      $check=mysqli_query($dbc,"select * from clients where firstname='$firstname' and 
      lastname='$lastname'");
      $checkrows=mysqli_num_rows($check);
      if($checkrows&gt;0)
      {
    print "customer exists";      
      }  
      else
      {  
          //insert results from the form input
          $query = "INSERT INTO clients(firstName, lastName) VALUES('$firstName', '$lastName')";
          $result = mysqli_query($dbc, $query) or die("Sorry, Duplicate Record.'$php_errormsg'");
          mysqli_close($dbc);
      }
      print '&lt;script type="text/javascript"&gt;'; 
      print 'alert("The Customer is NOW registered")'; 
      print '&lt;/script&gt;';  
  
  };
  ?&gt;
  </code></pre>