I have a form on my website that was not written by me and the person who did it wasn't very good (or reachable for that matter) so now by bosses want me to fix it. Currently the form on submit sends an emal and opens up a thank you message. Unfortunately that pop-up looks much more like an error message than a success message, so I was asked to redirect the submit button to an actually thank you page instead of a pop-up. Now I'm not very vast with PHP so I need some help.
HTML:
<form>
<div class="row">
<div class="six columns">
<label class="gfield_label" for="Name" style="display: block;">Name<span class="gfield_required">*</span></label>
<input type="text" id="Name" required class="mobile-four"/>
</div>
<div class="six columns">
<label class="gfield_label" for="Company" style="display: block;">Company</label>
<input type="text" id="Company" required class="mobile-four"/>
</div>
</div>
<div class="row">
<div class="six columns mobile-four">
<label class="gfield_label" for="email" style="display: block;">Email<span class="gfield_required">*</span></label>
<input type="email" class="mobile-four" id="email" required />
</div>
<div class="six columns mobile-four">
<label class="gfield_label" for="phone" style="display: block;">Phone<span class="gfield_required">*</span></label>
<input type="phone" class="mobile-four" id="phone" required />
</div>
</div>
<div class="row">
<div class="twelve columns mobile-four">
<label class="gfield_label" for="message" style="display: block;">Message<span class="gfield_required">*</span></label>
<textarea id="message" cols="30" rows="3"></textarea>
</div>
<div class="three columns centered">
<button id="contact-submit-btn" class="btn btn-block btn-danger">Contact us Now!</button>
</div>
</div>
</form>
PHP:
<?php
if($_POST){
$mailBody = "Name:" . $_POST['Name'] . "
Phone:" . $_POST['phone'] . "
Email:" . $_POST['email'] . "
Message:
" . $_POST['message'];
mail("a@harbordev.com","Website request from " . $_POST['Name'], $mailBody);
}
header("location:/thankyou.html");
?>
JS:
$(document).ready(function() {
$("#contact-submit-btn").click(function() {
var form_data = {
Name:$("#Name").val(),
Company:$("#Company").val(),
phone:$("#phone").val(),
email:$("#email").val(),
message:$("#message").val(),
is_ajax: 1
};
$.ajax({
type: "POST",
url: "/contactsubmit.php",
data: form_data,
cache: false,
success: function(result){
alert(result);
}
});//ajax
return false;
});
});
I would like the submit button to redirect to "contact-thanks.html", which isn't written in PHP. (thankyou.html is written in PHP, but all it contains is the tank you text).
Thanks for the help