So I'm trying to make a contact form with a button, not submit button, that runs a function when clicked onClick = 'send()' and on localhost w/ WAMP it works perfectly sending the email with its contents. On a live version, the connection is well and I receive the email but I don't get the respective form field data even though it's the same code I used when testing on WAMP server. Also, in the top of the php file I echoed the POST data and on localhost it would say the information but on live, again, it doesn't.
- I have also tried
.val()instead of.serialize()as shown below but no luck. - I have also done
data: {name:name, email:email...}as well asdata{'name':name, 'email':email...}
Any help would be appreciated!
Heres the AJAX:
function send(){
var name = $("input[name=name]").serialize();
var email = $("input[name=email]").serialize();
var textarea = $("textarea").serialize();
var business = $("input[name=business]").serialize();
var website = $("input[name=website]").serialize();
alert(name);
alert(email);
alert(textarea);
alert(business);
alert(website);
$.ajax({
url: 'sendmail.php',
type: 'POST',
data: {name, email, textarea, business, website},
success: function(mydata) {
alert(mydata);
}
});
}
and heres the PHP:
<?php
echo($_POST['name']);
// does show as output on localhost w/wamp but on live website its mute
$message=
'Full Name: '.$_POST['name'].'<br />
Email: '.$_POST['email'].'<br />
Message: '.$_POST['textarea'].'<br />
Current Website: '.$_POST['website'].'<br />
Business Name: '.$_POST['business'].'<br />
';
/* Email Sending Script */
if (!$mail->send()) {
echo $mail->ErrorInfo;
} else {
die("true");
}
?>
NETWORK TABS
Request Headers: http://prntscr.com/ck0btg
Post Data: http://prntscr.com/ck0cni
{name, email, textarea, business, website}is actually valid