与我们联系表格

时间:2019-07-08 16:56:11

标签: javascript php

我试图创建将邮件直接发送到我的电子邮件的联系表单,但是“输入中出现意外字符:'\'(ASCII = 92)state = 1',此错误始终到来

<?php

$from='Demao Contact Form <demo@domain.com>';
$sendTo='Demo Contact Form <demo@domain.com>';
$fields=array('name'=>'Name','surname'=>'Surname','phone'=>'Phone','email'=>'Email','message'=>'Message');
$okMessage='Contact form successfully submitted.Iwill get back to you!';
$errorMessage='There were errors while sending the email';

error_reporting(E_ALL & -E_NOTICE);
try{

    if(count($_POST)==0) {
        throw new \ Exception('Form is empty.');
                         }
    $emailText='you have a new message from your demo contact from.\n';

    foreach($_POST as $key => $value){
        if(isset($ields[$key])){
            $emailText .="fields[$key] : $value\n";
        }
    }
    $headers = arrat('Content-Type: text/plain;charset="UTF-8";',
        'From:' . $from,
        'Reply-To: ' . $from,
        'Return-Path: ' . $from
        );
    mail($sendTo,$subject,$emailText, implode("\n",$headers));
    $responseArray= array("type" =>'sucess','message' =>$okMessage);
}
catch(\Exception $e)
{
    $responseArray = array("type" => 'danger','message'=>$errorMessage);
}
if(empty($_SERVER['HTTP_X_REUESTED_WITH']) & strtolower($_SERVER['HTTP_X_REUESTED_WITH']) =='xmlhttprequest'
  ){
    $encoded= json_encode($responseArray);

    header('Content-Type: application/json');
    echo $encoded;
}
?>

警告:第13行的C:\ wamp \ www \ contact.php中的输入字符:'\'(ASCII = 92)state = 1

警告:第30行的C:\ wamp \ www \ contact.php中的输入字符:'\'(ASCII = 92)state = 1

0 个答案:

没有答案