I know what you're thinking of commenting, "this is a duplicate answer" - this isn't completely true, I've searched high to low to find out how to do it but I can't seem to find anything.
The question, how can I replace a form with a thank you message? This is different because I my form submits to a php page which contains sql connecting and adding the form DATA to a database in MYSQL. When submitting the data it adds to the database. But it stays on the php page.
Heres my code:
<div class="index-contant">
<div class="margin">
<h2>GET A FREE QUOTE</h2>
<div class="row" style="margin-left:auto !important; margin-right:auto !important; display:block !important;">
<form name="contactForm" action="php/sql_insert.php" method="GET">
<div class="col-sm-4 col-md-4">
<input type="text" class="form-control" name="name" id="name" placeholder="*Name" id="name"required>
<br>
<input type="email" class="form-control" name="email" id="email" placeholder="*Email" id="email"required>
<br>
<input type="text" class="form-control" name="subject" id="subject" placeholder="*Subject" id="subject" required>
</div>
<div class="col-sm-8 col-md-8">
<textarea class="form-control textarea-resize" rows="7" id="message" name="message" placeholder="*Message" required></textarea>
</div>
<p style="padding:0 !important; margin:0 !important">   </p>
<div style="margin-left:15px; margin-right:15px;">
<input type="submit" class="button form-submit" value="SEND">
</div>
</form>
</div>
</div>
</div>
<?php
include('sql_connect.php');
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$sql="INSERT INTO $tbl_name(name, email, subject, message)VALUES('$name', '$email', '$subject', '$message')";
$result=mysql_query($sql);
?>
<?php
// close connection
mysql_close();
?>
I want to be able to send the data to MySQL and stay on the same page. And then replace the form with a thank you message. I have tried using GET and POST, neither of them keep me on the same page.