title: Execute php file with Ajax
body: <p>When I click on "Register Now" Button, I want to execute 'input.php' in which I have code to insert my data to the database and show a success message. I don't want to leave current page.</p>
  
  <pre><code>&lt;input type="button" id="confirm" value="Register Now" class="button"&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function() {
    $("#confirm").click(function() {
      &lt;?php
      include 'input.php';
      ?&gt;
      alert ("data Added successfully.");
    });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>My code is giving me "data Added successfully" message but PHP file hasn't executed and no data is added to the database. All necessary data is in session variables.</p>