PHP联系表:有时它有用,但大多数时候它不起作用

时间:2018-11-05 16:06:53

标签: php contact-form

所以我有一个非常简单的联系表(尽管内容有点繁琐)。而且我无法弄清楚为什么我的生命中有十分之一实际上发送了电子邮件...更多时候,它什么都不做,而是将我重定向到“谢谢”页面...它实际上是发送还是不发送。而且大部分都不是...

代码如下:

<?php
$EmailFrom = "JadeCollection";
$EmailTo = "curtissteeleforever@gmail.com,brandon@neuelane.com";
$Subject = "Someone is trying to reach you from JadeSignatureCollection.com";
$fName = Trim(stripslashes($_POST['FirstName']));
$lName = Trim(stripslashes($_POST['LastName']));
$email = Trim(stripslashes($_POST['Email']));
$company = Trim(stripslashes($_POST['Company']));
$phone = Trim(stripslashes($_POST['Phone']));
$country = Trim(stripslashes($_POST['Country']));
$addy = Trim(stripslashes($_POST['Address']));
$city = Trim(stripslashes($_POST['City']));
$state = Trim(stripslashes($_POST['State']));
$zip = Trim(stripslashes($_POST['Zip']));
$reference = Trim(stripslashes($_POST['HowDidYouHearAboutUs']));
$interests = Trim(stripslashes($_POST['Interested']));
$comments = Trim(stripslashes($_POST['Comments']));

// validation
$validationOK=true;
if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    exit;
}

// prepare email body text
$Body = "";
$Body .= "First Name: ";
$Body .= $fName;
$Body .= "\n";
$Body .= "Last Name: ";
$Body .= $lName;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $company;
$Body .= "\n";
$Body .= "Phone Number: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $country;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $addy;
$Body .= "\n";
$Body .= "City: ";
$Body .= $city;
$Body .= "\n";
$Body .= "State: ";
$Body .= $state;
$Body .= "\n";
$Body .= "Zip Code: ";
$Body .= $zip;
$Body .= "\n";
$Body .= "How did you hear about us?: ";
$Body .= $reference;
$Body .= "\n";
$Body .= "Interested in: ";
$Body .= $interests;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $comments;

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.php\">";
} else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

0 个答案:

没有答案