title: Send html form data to database through php without switching page
body: <p>Hey guys so i have a form:</p>
  
  <pre><code>&lt;form action="signup.php" method="post" class="cd-form"&gt;
                  &lt;p class="fieldset"&gt;
                    &lt;input class="full-width has-padding has-border" type="text" required maxlength="15" placeholder="First Name" name="primeiro_nome" /&gt;         
                &lt;/p&gt;
                  &lt;p class="fieldset"&gt;
                    &lt;input class="full-width has-padding has-border"  type="text" required  maxlength="15" placeholder="Last Name" name="segundo_nome"&gt;
                  &lt;/p&gt;
                  &lt;p class="fieldset"&gt;
                    &lt;input class="full-width has-padding has-border"  type="email" required maxlength="50"  placeholder="E-mail" name="o_email"&gt;
                  &lt;/p&gt;
                  &lt;p class="fieldset"&gt;
                      &lt;input class="full-width" type="submit" value="Sign Up!"&gt;
                  &lt;/p&gt;        
              &lt;/form&gt;
  </code></pre>
  
  <p>And you may notice that the action is calling "signup.php" :</p>
  
  <pre><code>    &lt;?php
   $con=new mysqli ("localhost","root","","chroniclemark");
      mysqli_set_charset($con, 'utf8mb4');
      if($con-&gt;connect_error)
      {
          echo $con-&gt;connect_errno;
          die("Database Connection Failed");
      }
      if(($_POST['primeiro_nome']) != ""){
  
      $sql = "INSERT INTO users (nome, sobrenome, email) 
               VALUES('{$con-&gt;real_escape_string($_POST['primeiro_nome'])}', '{$con-&gt;real_escape_string($_POST['segundo_nome'])}', '{$con-&gt;real_escape_string($_POST['o_email'])}')";
          $insert = $con-&gt;query($sql);
  
  }
  ?&gt;
  </code></pre>
  
  <p>And this is working. The data from the form is getting inserted into my database. The problem i have is that the main page closes when the form is submitted and the "signup.php" page opens instead of it.</p>
  
  <p>How do i fix this? I would very much like to have a "Thank you for signing up" popping up on the same page instead of it switching to another one.</p>