I am creating a sign up form. Instead of using $_POST I used jQuery to get the form data and I'd like to send an email to the customer. The signup page is working property but i am having trouble to send an email with the data.
Here is the button to send the data
<button type="button" class="next action-button" id="fourthnext" >Register</button>
if($input.attr("id") == "fourthnext"){
//some code
$.ajax({
type: 'POST',
url : path_to_functions,
data: data1,
success: function(data){
if (data!='') {
finalerror.html(data);
finalerror.show();
fourthstepload.hide();
show_result();
//Disable the button and test the user to go back #TODO
throw new Error();
}else{
finalerror.html(data);
finalerror.show();
fourthstepload.hide();
}
}
});
show_result() function is called for any call flow the customer chooses so I think i can include the mail function in it. i have a simple mail php file for testing but its not even called.
var path_to_mail = path.href+'mailtest.php';
function show_result(){
console.log("Debug start");
$.ajax({
type: "POST",
url : path_to_mail,
success: function(){
console.log('success');
},
error : function(){
console.log('error');
}
});
//rest of the code works properly such as
$(".final_company").html($("#companyname").val());
$("#final_login").html($("#inputEmail4").val());
//hide previous step
$(".hidemewhendone").hide();
//show Result step
$(".final_fieldset").show();
I could include more or the full code if the information I provided is not sufficient enough. Thank you
mailtest.php is literally just
<?php mail($myemail, "test", "message", $headers);?>
source https://stackoverflow.com/questions/69366487/sending-email-with-php-and-ajax
Comments
Post a Comment