How would I get my page to redirect when the form is submitted successfully?
Currently when the form is submitted with an error, the error appears above the form.
When the form is submitted without an error, the success page is shown INSIDE the error message container above the form (instead of redirecting).
My Ajax:
function checkform() {
var form = $('form')[0];
var data = new FormData(form);
$.ajax({
url: 'upload.php',
data: data ,
processData: false,
contentType: false,
dataType: 'text',
cache: false,
type: 'POST',
success: function(data){
$("div#error").html(data).slideDown("fast");
//Scroll to top of this div - 70px from the top of your view, change this to whatever number you wish
var destination = $('div#uploadContainer').offset().top - 15;
$("html:not(:animated),body:not(:animated)").animate({
scrollTop: destination
}, 200);
}
});
return false;
}
My PHP (after the validation etc...)
if (isset($_POST['messageSubmit'])) {
header('Location: ' . $message_location);
}
if (isset($_POST['drawingSubmit'])) {
header('Location: ' . $drawing_location);
}
if (isset($_POST['postSubmit'])) {
header('Location: ' . $other_location);
}