title: How to remain on a page after submitting a form using PHP and update it?
body: <p>I'm struggling to find an answer to my question..</p>
  
  <p>The website I'm creating contains a form in which users can enter Name and Email which is then forwarded using PHP to my email address (working).</p>
  
  <p>Once the form is submitted the email is sent but currently I am redirected to the PHP file. I'm wondering how to remain on the same page and then update the sign up button text to "submitted".</p>
  
  <p>This is the code so far..</p>
  
  <p>PHP: </p>
  
  <pre><code>&lt;?php
  if(isset($_POST['email'])) {
  
  $email_to = "myemailaddress@test.com";
  $email_subject = "New Subscriber";
  
  $name = $_POST['name']; 
  $email = $_POST['email']; 
  
  function clean_string($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    return str_replace($bad,"",$string);
  }
  
  $email_message = "Name: ".clean_string($name)."\n";
  $email_message .= "Email: ".clean_string($email)."\n";
  
  $headers = 'From: '.$name."\r\n".
  'Reply-To: '.$email."\r\n" .
  'X-Mailer: PHP/' . phpversion();
  @mail($email_to, $email_subject, $email_message, $headers);  
  
  }?&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form action="send_form_email.php" method="post"&gt;
      &lt;input placeholder="Name" type="text" name="name" class="name"&gt;
      &lt;input placeholder="Email address" type="text" name="email" class="email"&gt;
      &lt;button type="submit" class="sign-up" value="Press here" id="test"&gt;Sign up&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>