I've a form that outputs URL string like:
address=someaddress&title=Title&name=Author&mail=authorsmail&message=Somemessage
(I'm doing it using jQuery AJAX function)
$.ajax({
type: "POST",
url: "send.php",
data: myString,
(...)
Anyways, there is something wrong with my send.php file, because I'm trying and trying and I'm unable to get any mails.
$mailTo = Trim(stripslashes($_GET['address']));
$subject = Trim(stripslashes($_GET['title']));
$name = Trim(stripslashes($_GET['name']));
$emailFrom = Trim(stripslashes($_GET['mail']));
$message = Trim(stripslashes($_GET['message']));
$Body = $message;
$success = mail($mailTo, $subject, $Body, "From: <$emailFrom>");
It doesn't work when i change all $_POST to $_GET.
What's wrong?
Thanks.
if you change post to get you must change the php variable $_POST
to $_GET
for example
Trim(stripslashes($_POST['address']));
to
Trim(stripslashes($_GET['address']));
Or you can use $_REQUEST, which works with either POST or GET.
I think something is wrong with your question.
You say your AJAX script results in a URL string such as address=someaddress&title=Title&name=Author&mail=authorsmail&message=Somemessage
, yet your AJAX type is set to POST, which would not result in that URL. Are you sure your JavaScript is working properly? Are you sure your JavaScript is stopping the actual form submission?