【发布时间】:2015-01-08 06:59:27
【问题描述】:
我正在编辑一个 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 . ")");
}
?>
任何帮助将不胜感激,谢谢。
更新 这是完整的页面...... http://pastebin.com/vyT6J4PH http://pastebin.com/kk2Byy6S
【问题讨论】:
-
数据是如何发送到服务器的?
-
选择的是哪个元素?如果没有表单的代码,我们无法重现问题。
-
@charlietfl 它是使用 wordpress 函数发送的 $result = wp_mail($email_to, $subject, $text, $headers);
-
@JeremiahWinsley select元素在上面,它的名字和ID是“question”。
-
来自客户端的数据不是通过wordpress函数发送的,它要么是通过ajax提交,要么是默认表单提交
标签: php wordpress select options