I am trying to email a string that was collected from a web page via php, however I am not having any luck. Lots of info on making jQuery forms but can't find any that are simply emailing a string.
here is what I have so far:
$('.questionFive').click(function(){
$.post("mail.php", preSubmit())
});
// this works well, and returns the string as desired.
function preSubmit(){
var optionTexts = [];
$("section").each(function(){
var h2 = $(this).find("h2").text();
optionTexts.push(h2);
$("ol li", this).each(function() { optionTexts.push($(this).text()) });
optionTexts.push("
");
});
var optionString = optionTexts.toString();
var splitText = optionString.split(",");
alert(splitText);
return splitText;
}
// mail.php file
<?php
if (isset($_POST['mailstring']) {
$mail = $_POST['mailstring'];
mail('me@email.com', 'My Subject', $mail);
}
?>