Please I need your help about my basic php practice. Please check below is my code. I have added action of my form by different php file. I want after submit my form. I will see this message Successfully Submitted after showing this thank you message redirect to index.php page again but now this page don't redirect. It's stay contact.php page. Thanks.
<?php
if(isset($_POST['submit'])){
$sub = "New Message";
$to = "musar001@gmail.com";
$email = $_POST['email'];
$message = "Your Name:" . " " .$_POST['name'] . "\r\n";
$message .= "Your E-mail:" . " " . $_POST['email'] . "\r\n";
$message .= "Mobile Number:" . " " . $_POST['mobile'] . "\r\n";
$message .= "Country Name:" . " " . $_POST['country'] . "\r\n";
$message .= "I have dog(s):" . " " . $_POST['dog'] . "\r\n";
$message .= "And Cat(s):" . " " . $_POST['cat'] . "\r\n";
$headers = "From: $email" . "\r\n";
$success = mail($to, $sub, $message, $headers);
if(isset($_POST) && $success) {
echo "<h2>Successfully Submitted. Thanks.</h2>";
//If I use header function I can't see thank you message.
// header('location: index.php');
}
}
?>
Few Example of html code.
<form action="contact.php" method="POST" id="contactform" class="wpcf7-form contactform-v2">
<div class="row">
<div class="col-xs-6 col-sm-6">
<p class="contact-form-author">
<input type="text" required="required" value="" name="name" id="name" placeholder="Your Name *"></p>
</div>
<div class="col-xs-6 col-sm-6">
<p class="contact-form-email">
<input type="email" required="required" value="" name="email" id="email" placeholder="Your Email *"></p>
</div>
</div>
</form>
I didn't find any answer of my question.??