Display message on subscribe button html php form

i am trying above but message is displayed on php page.instead of reloading SAME PAGE AND DISPLAY MESSAGE ABOVE SUBSCRIBE FORM ITS REDIRECTING TO PHP PAGE.You can check on test site link attached.Form is on deck
page.I tried to reload page through jquery onload and onclick onsubmit but didnt worked.below are test which i did.

//form is on index.html page
       <!-- your form here -->
   <div class="text-center">
   <form action="forms/subscribe.php"id="form" method="post">
   <div class="mb-3">
                   <div class="loading">Loading</div>
                   <div class="error-message"></div>
                   <div class="sent-message">Your message has been sent. Thank you!</div>
                 </div>
    <input type="email"  name="email" placeholder="Enter your Email">
    <input type="submit" value="Subscribe">
               </form>
   </div>
   //form is on index.html page
   <div class="row footer-newsletter justify-content-center">
         <div class="col-lg-6">
           <form action="forms/subscribe.php" method="post">
             <input type="email" name="email" placeholder="Enter your Email">
             <input type="submit" value="Subscribe" onclick="alert();window.location.reload();">
           </form>
         </div>
         
         
           
   <!DOCTYPE html>
   <html>
   <body>
   
   <button onclick="myFunction()">Click me</button>
   
   <p id="demo"></p>
   
   <p>A function is triggered when the button is clicked. The function outputs some text in a p element with id="demo".</p>
   
   <script>
   function myFunction() {
     document.getElementById("demo").innerHTML = "Hello World";
   }
   </script>

My php page

<?php
    if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "Subscriber from Website";

function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
  }


// validation expected data exists
   if(!isset($_POST['email'])) {
    died('We are sorry, but there appears to be a problem with the form you submitted.');       
  }


$email_from = $_POST['email']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

  if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }

$email_message = "Form details below.\n\n";

 
function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
   }

$email_message .= "Subscriber Contact Email::".clean_string($email_from)."\n";

// create email headers
 $headers = 'From: '.$email_from."\r\n".
 'Reply-To: '.$email_from."\r\n" .
 'X-Mailer: PHP/' . phpversion();
 @mail($email_to,$email_subject, $email_message, $headers);  
 ?>

  <!-- include your own success html here -->
            Thank you for contacting us. We will be in touch with you very soon.


 <?php

  }
   ?>

Check test site below

http://shreemat.onlinewebshop.net/

If you don’t want the page submitting, you need to use an AJAX call to the backend, I don’t see that anywhere?

Warning : Cannot modify header information - headers already sent by (output started at /srv/disk10/3056255/www/shreemat.onlinewebshop.net/forms/subscribe.php:36) in /srv/disk10/3056255/www/shreemat.onlinewebshop.net/forms/subscribe.php on line 37

Sponsor our Newsletter | Privacy Policy | Terms of Service