title: How to return to the previous page after a submit form with php?
body: <p>I have a form in html whose "action" attribute calls a contact.php file. The problem is that after I submit the form, the file that is visible is a blank page with the address contact.php and I want to see again the form of the main page.</p>
  
  <pre><code>HTML:
  &lt;form id="myForm" action="php-contact/contact.php"
                         method="post" class="contact_form" autocomplete="off"
                         role="form"&gt;
                            &lt;div class="form-group"&gt;
                              &lt;label for="input-subject"&gt;subject&lt;/label&gt;
                              &lt;input name="subject" type="text" class="form-control" id="subject" placeholder="your subject" maxlength="20"/&gt;
                            &lt;/div&gt;
  
                            &lt;div class="form-group"&gt;    
                                &lt;label for="input-name"&gt;name&lt;/label&gt;
                                &lt;input name="name"  type="text" class="form-control" id="name" placeholder="your name" maxlength="20"/&gt;
                            &lt;/div&gt;
  
                            &lt;div class="form-group"&gt;    
                              &lt;label for="input-email"&gt;email address&lt;/label&gt;
                              &lt;input name="email"  type="text" class="form-control" id="email" placeholder="your email" maxlength="40"/&gt;
                            &lt;/div&gt; 
  
                            &lt;div class="form-group" &gt;   
                                &lt;label for="input-message"&gt;message&lt;/label&gt;
                                &lt;textarea name="message" cols="10" rows="10"  class="form-control" id="comment" &gt;&lt;/textarea&gt;
                            &lt;/div&gt;  
  
                            &lt;button name="myFormSubmitted" type="submit" class="btn btn-primary btn-lg btn-block"&gt;send&lt;/button&gt;
                        &lt;/form&gt;
  
  PHP:
    &lt;?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
  
    $to = "pep.g@gmail.com";
    $message = '
    name: '.$name.'
    email: '.$email.'
     message: '.$message.'
    ';
  
   $headers = 'From: pep.website@website.com';
  
     if (
      mail($to, $subject, $message, $headers)
  ) 
        echo"&lt;script&gt;alert('message send succesfully')&lt;/script&gt;";
     else
        echo"&lt;script&gt;alert('message not send')&lt;/script&gt;";
  
   ?&gt;
  </code></pre>