开发者

Sending mails in PHP

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: m开发者_运维知识库yString,
(...)

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.


Or you can use $_REQUEST, which works with either POST or GET.


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']));


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜