【发布时间】:2014-09-16 23:38:05
【问题描述】:
我是 php 新手,非常感谢任何人对此提供的帮助!这是我的复选框代码的示例:
<legend>Fiction of Interest</legend>
<p class="group">Please check the literary genres that are of interest to you:</p>
<ul class="formList">
<li>
<input type="checkbox" name="fictioninterest[]" value="literaryfiction" id="lfitem"
<?php if ((isset($fictioninterest)) && (in_array("literaryfiction", $fictioninterest))) { echo "checked"; } ?> />
<label for="in">Literary Fiction</label>
这是我的单选按钮代码示例:
<legend>Connecting with the Author</legend>
<p class="group">Would you like to coincide your Book Club event with the author's BlogTalk radio interview?</p>
<p class="group">
<label>
<input type="radio" name="blogtalk" value="yes" id="yesitem" <?php if ((isset($blogtalk)) && ($blogtalk==='yes')) { echo "checked"; } ?> />
<label for="yesitem">Yes</label>
<br>
<label>
<input type="radio" name="blogtalk" value="no" id="noitem" <?php if ((isset($blogtalk)) && ($blogtalk==='no')) { echo "checked"; } ?> />
<label for="noitem">Not at this time</label>
</p>
这是我的文本区号:
<p class="group">
<label for="comments" class="text">Additional comments</label>
<textarea name="comments" id="comments">
<?php if (isset($comments)) { echo $comments; } ?></textarea>
</p>
我将非常感谢任何帮助!非常感谢!
我很抱歉 - 正如我所说的,我正在尝试自学 php,但即使是基础知识,我仍然在摸索。当我的表单被处理并将结果发送到电子邮件时,即使我选择了几个,复选框也会返回注册“null”。单选按钮也返回“null”。并且没有内容从我的文本区域部分传输到电子邮件。很抱歉没有正确解释,再次感谢您的帮助!
<?php
require_once("included_functions.php");
if (($_SERVER['REQUEST_METHOD'] == 'POST') && (!empty($_POST['action']))):
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$formerrors = false;
if ($name === '') :
$err_name = '<div class="error">Sorry, your name is a required field</div>';
endif; // input field empty
if ($email === '') :
$err_email = '<div class="error">Sorry, your email is a required field</div>';
endif; // input field empty
if (isset($_POST['comments'])) {
$comments = filter_var($_POST['comments'], FILTER_SANITIZE_STRING );
}
$formdata = array (
'name' => $name,
'email' => $email,
'fictioninterest' => $fictioninterest,
'bookclub' => $bookclub,
'newsletter' => $newsletter,
'blogtalk' => $blogtalk,
'skype' => $skype
);
if (!($formerrors)) :
$to = "bookclub@literaryfictionreview.com";
$subject = "From $name -- Signup Page";
$message = json_encode($formdata);
$replyto = "From: bookclub@literaryfictionreview.com \r\n".
"Reply-To: bookclub@literaryfictionreview.com \r\n";
if (mail($to, $subject, $message)):
$msg = "";
redirect_to("confirmation.html");
else:
$msg = "Problem sending the message";
endif; // mail form data
endif; // check for form errors
endif; //form submitted
?>
【问题讨论】:
-
你有什么问题?
-
由于您没有显示任何实际的 php 处理代码,我们无法真正帮助您。
-
提示:计算右/左括号的金额。
-
var_dump($fictioninterest);打印什么? (放在开头,在调用isset($fictioninterest)之前) -
我已经在上面添加了我的 php 处理代码,并且更清楚地解释了我的问题 - 非常感谢您尝试帮助我!