title: Php post form without refresh page
body: <p>I try to post my form to Mysql without refreshing page. I did these with looiking sources but not working. Could you help me?</p>
  
  <pre><code>&lt;script&gt;
  $('#submit').click(function() {
      $.ajax({
          url: 'submit.php',
          type: 'POST',
          data: {
              message: '*I couldnt find this partwhat should i write*'
          }
          }               
      });
  });
  &lt;/script&gt;
  
  &lt;form method="post"&gt;
  &lt;textarea name="message" rows="3" cols="30"&gt;
  &lt;/textarea&gt;&lt;br&gt;&lt;br&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Submit.php</p>
  
  <pre><code>&lt;?php
  include "connect.php";
  if(isset($_POST['message'])) {
      header('Location: ' . $_SERVER['HTTP_REFERER']);
      $post = $_POST['message'];
      $date = date("y-m-d G:i:s"); 
  
      $query = $db-&gt;prepare("INSERT INTO chat_messages SET senderid = ?, receiverid = ?, message = ?, mod_time = ?"); 
      $insert = $query-&gt;execute(array( $a, $b, $post, $date));
  }?&gt;
  </code></pre>