0

我的联系表单脚本中的项目和电话字段不起作用。任何我做错的想法,因为其他所有领域都很好:

<? php
include('contact-config.php');
$contact_form_version = strtolower($contact_form_version);
if (empty($to) || empty($contact_form_version) || ($contact_form_version != 'php' && $contact_form_version != 'html')) {
die('Error: The contact form has not been setup correctly.');
} else {
if ($contact_form_version == 'php') {
    $formLocation = 'contact.php';
} else if ($contact_form_version == 'html') {
    $formLocation = 'contact.html';
}
}
if (!empty($_POST['isAjax']) && $_POST['isAjax'] == '1') {
$ajax = true;
} else {
$ajax = false;
}
if (empty($_POST['name']) || empty($_POST['project']) || empty($_POST['email']) ||  empty($_POST['phone']) || empty($_POST['message'])) {
if ($ajax || $contact_form_version == 'html') {
    die('Error: Missing variables');
} else {
    header("Location: $formLocation?msg=missing-variables");
    exit;
}
}
if (!preg_match("/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$/", $_POST['email'])) {
if ($ajax || $contact_form_version == 'html') {
    die('Error: Invalid email address');
} else {
    header("Location: $formLocation?msg=invalid-email-address");
    exit;
}
}
$name = $_POST['name'];
$project = $_POST['project'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$code = $_POST['captcha'];
$eip = $_POST['eip'];
$to = $to;
$headers = 'From: '.$name.' <'.$email.'>'." \r\n";
$headers. = 'Reply-To: '.$email."\r\n";
if (isset($cc) && $cc != '') {
$headers. = 'Cc: '.$cc."\r\n";
}
if (isset($bcc) && $bcc != '') {
$headers. = 'Bcc: '.$bcc."\r\n";
}
$headers. = 'X-Mailer: PHP/'.phpversion();
$subject = 'Contact Form Enquiry';
$message = wordwrap($message, 70);
if (mail($to, $subject, $message, $headers)) {
if ($ajax || $contact_form_version == 'html') {
    die('Mail sent');
} else {
    header("Location: $formLocation?msg=mail-sent");
    exit;
}
} else {
if ($ajax || $contact_form_version == 'html') {
    die('Error: Mail failed');
} else {
    header("Location: $formLocation?msg=mail-failed");
    exit;
}
} ?>

任何对此的帮助将不胜感激。

谢谢一堆

4

2 回答 2

0

我今天有同样的问题,我通过改变这个来解决:

else {
    header("Location: $formLocation?msg=missing-variables");
    exit;
}

 else {
    header("Location: thank-you.html"); 
    exit;
}

注意:我创建了一个文件并命名为thank-you。

我的错!我有重定向问题..

于 2014-02-03T19:29:22.170 回答
0

您实际上并未发送详细信息尝试。

$name = $_POST['name'];
$project = $_POST['project'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$code = $_POST['captcha'];
$eip = $_POST['eip'];

$content = $name . ' ' . $project . ' ' . $email . ' ' . $phone . ' ' . $message . ' ' . $code . ' ' . $eip;

if (mail($to, $subject, $content, $headers)) {
于 2013-08-23T15:47:38.370 回答