简体   繁体   English

联系表单字段未发送

[英]Contact Form Fields not being sent

The project and phone fields in my contact form script arent working. 我的联系表单脚本中的项目和电话字段无法正常工作。 Any ideas what I'm doing wrong as every other field works great: 任何我在其他领域都做错的事情都很棒:

<? 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;
}
} ?>

Any help with this would be hugely appreciated guys. 任何与此有关的帮助将非常感谢。

Thanks a bunch 谢谢一大堆

Your not actually sending the details try. 您实际上没有发送详细信息,请尝试。

$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)) {

I had same problem today , I fixed by changing this : 我今天遇到了同样的问题,我通过更改此方法来解决:

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

To

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

NB: I created a file and called thank-you . NB:我创建了一个文件,并将其命名为thank-you。

My bad! 我的错! I had problem with redirection .. 我在重定向方面有问题..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM