选择不在Wordpress联系表单PHP中给出值的选项

时间:2014-11-11 16:35:54

标签: php wordpress select options

我正在编辑Wordpress主题联系表单。我正在添加一个选择下拉菜单,根据选择的选项,电子邮件将被发送到不同的地址。 我的WP选项工作正常,我测试了它。问题是选择框。由于某种原因,选择值在电子邮件中显示为空白,因为它的空白,我无法使其余的逻辑功能正常。

                                <div class="column1">
                                <select class="selectclass" name="question" id="question">
                                    <option value ="9" selected>What is your question?</option>
                                    <option value ="1">I would like to see a demo</option>
                                    <option value ="2">I’d like to learn more about native advertising</option>
                                    <option value ="3">I am a publisher and  interested in seeing products</option>
                                    <option value ="4">I am an advertiser and I want to speak to a sales representative</option>
                                    <option value ="5">I am interested in partnering with Content That Works</option>
                                    <option value ="6">I have an issue with my billing</option>
                                    <option value ="7">There is something technically wrong with your website</option>
                                    <option value ="8">Other questions</option>
                                </select>
                                </div>




<?php
require_once('recaptchalib.php');
require('../../../../wp-blog-header.php');
global $qode_options_proya;

$publickey = $qode_options_proya['recaptcha_public_key'];
$privatekey = $qode_options_proya['recaptcha_private_key'];

if ($publickey == "") $publickey = "6Ld5VOASAAAAABUGCt9ZaNuw3IF-BjUFLujP6C8L";
if ($privatekey == "") $privatekey = "6Ld5VOASAAAAAKQdKVcxZ321VM6lkhBsoT6lXe9Z";

$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
$quest = $_POST["question"];

$use_captcha = $qode_options_proya['use_recaptcha'];
if ($resp->is_valid || $use_captcha == "no") {
    ?>success<?php

    $email_to = $qode_options_proya['native_mail'];

    $email_from = $qode_options_proya['email_from'];
    $subject = $qode_options_proya['email_subject'];

    $text = "Name: " . $_POST["name"] . " " . $_POST["lastname"] . "\n";
    $text = "Question: " . $_POST["question"] . "\n";
    $text .= "Email: " . $_POST["email"] . "\n";
    $text .= "WebSite: " . $_POST["website"] . "\n";
    $text .= "Message: " . $_POST["message"];

    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/plain; charset=utf-8" . "\r\n";
    $headers .= "From: '".$_POST['name']." ".$_POST['lastname']."' <".$email_from."> " . "\r\n";

    $result = wp_mail($email_to, $subject, $text, $headers);


    if(!$result) {
        global $phpmailer;
        var_dump($phpmailer->ErrorInfo);
    }
}
else {
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .  "(reCAPTCHA said: " . $resp->error . ")");
}
?>

非常感谢任何帮助,谢谢。

UPDATE 这是完整的页面.... http://pastebin.com/vyT6J4PH http://pastebin.com/kk2Byy6S

1 个答案:

答案 0 :(得分:0)

表单问题是AJAX提交功能。

        challengeField = $j("input#recaptcha_challenge_field").val();
        responseField = $j("input#recaptcha_response_field").val();
        name =  $j("input#fname").val();
        lastname =  $j("input#lname").val();
        email =  $j("input#email").val();
        website =  $j("input#website").val();
        message =  $j("textarea#message").val();

        var form_post_data = "";

        var html = $j.ajax({
        type: "POST",
        url: "<?php echo QODE_ROOT; ?>/includes/ajax_mail.php",
        data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField + "&name=" + name + "&lastname=" + lastname + "&email=" + email + "&website=" + website + "&message=" + message,
        async: false
        }).responseText;

选择元素未与其他元素一起提交。

        question = $j("select#question").val();

        data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField + "&name=" + name + "&lastname=" + lastname + "&email=" + email + "&website=" + website + "&message=" + message + "&question=" + question,

应该解决你的问题。