I am working on an html page having a subscription section. The users puts his/her email in an input field and submit it. The control is then transferred to a php page which emails the subscription message to the website admin if the message is sent successfully it navigates back to index.html. Now at this point i want to show an alert message that subscription was successful or unsuccessful. How can i do that without making my index.html index.php.
<?php
$to = "@gmail.com";
$from = "edmin.media@gmail.com";
$headers = "From: " . $from . "\r\n";
$subject = "New subscription";
$body = "Dear Admin!\nNew user subscription: " . $_POST['email'];
if( filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
if (mail($to, $subject, $body, $headers, "-f " . $from)) {
@header('location:index.html');
} else {
@header('location:index.html');
}
} else {
@header('location:index.html');
}
?>