2013-07-06 159 views
0

我添加了一个干净的()函数给我联系我的表单去除特殊字符,由于某种原因它只是发送空白消息,没有主题,什么都没有。如果我从字符串中删除函数,那么它就可以工作。PHP电子邮件表格发送空白邮件

下面是窗体的一部分:

function clean($string) { 
preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags(html_entity_decode($string))); 
} 

if (isset($_REQUEST['email'])) 
    {//if "email" is filled out, proceed 

    //check if the email address is invalid 
    $mailcheck = spamcheck($_REQUEST['email']); 
    if ($mailcheck==FALSE) 
    { 
    echo "Invalid input. Please <a href='http://pattersoncode.ca/index.php?a=help'>try again</a>"; 
    } 
    else 
    {//send email 
    $email = $_REQUEST['email'] ; 
    $product = clean($_REQUEST['product']); 
    $message = clean($_REQUEST['message']); 
    mail("[email protected]", "Subject: $product", 
    $message, "From: $email"); 
    echo "I'll be in contact shortly, thanks! :)"; 
    } 
+2

你没有从你的函数返回任何值 –

回答

2

您需要回报从你的函数的值。

function clean($string) { 
return preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags(html_entity_decode($string))); 
}