After completing the registration form, I want you to be sent a message saying “Your message is being sent” and then be directed to the thank you page.
But I couldn’t because I don’t have much js and php knowledge.
PHP MAILER Version: Latest Version
Resigtration.html JS Code
<script type="text/javascript">
function send_special_order() {
var data1 = $('#fname').val();
var data2 = $('#lname').val();
var data3 = $('#dob').val();
var data4 = $('#gender').val();
var data5 = $('#veliad').val();
var data6 = $('#vsoyad').val();
var data7 = $('#phone').val();
var data8 = $('#email').val();
var data9 = $('#adres').val();
var data10 = $('#Location').val();
$.ajax({
type: "POST",
url: "registration.php",
dataType : "json",
data: ( {"fname" : data1, "lname" : data2, "dob" : data3,"gender" : data4,"veliad" : data5,"vsoyad" : data6,"phone" : data7,"email" : data8,"adres" : data9,"Location" : data10} ) ,
success: function() {},
complete: function() {
$('#feedback').append('<p>Bize mesaj gönderdiğiniz için teşekkür ederiz. Uzmanlarımız en kısa sürede sizinle iletişime geçecektir.</p>');
$('#contact-form').slideUp();
}
});
}
$('#contact-form').submit(function() {
send_special_order();
return false;
});
</script>
<script type="text/javascript">
function checkForm(form) // Submit button clicked
{
//
// check form input values
//
form.myButton.disabled = true;
form.myButton.value = "Gönderiliyor...";
return true;
}
function resetForm(form) // Reset button clicked
{
form.myButton.disabled = false;
form.myButton.value = "Submit";
}
</script>
Registration.php Page code
if(!$mail->Send()){
echo "Mesaj hatası: ".$mail->ErrorInfo;
} else {
echo "Mesaj Gönderildi";
}
?>
2
Answers
I solved my problem with the following code.
You will need to search some knowledge about it.
To explain you a bit :
in your $.ajax() you will make a POST Request POST AND GET REQUEST
in this request you have a
success: function() {}
this “success” function will be called once your request is success.
So in this function you can implement what you want to do next.
A basic way of prompting a message using alert()
and to redirect your user :
you can use window.location to the desire url
For example i take only your Ajax sample :