向.csv提交网络表单信息时出错

时间:2011-09-19 10:07:10

标签: php forms

我正在使用PHP脚本作为简单的注册表单,当您输入信息并单击“提交”时,它会将数据发送到.csv文件而不是数据库。

最初这个脚本是一个只有电子邮件和名称字段的Beta启动页面,但我后来又添加了一个问题“你能参加吗?”使用“是”或“否”单选按钮作为选项。

我测试了表单,它的工作方式。数据将发送到.csv文件,并带有“您能参加吗?”的新列。问题,但无论你放什么('是'或'否').csv文件总是显示'是'作为表格中提交的数据。

相当多的代码,但这里是index.php页面的代码:http://pastebin.com/XLy62q7A,这里是submit.php页面的代码:http://pastebin.com/XvYCFSwY

我已经在PHP'出席'中提出了这个问题,所以无论你认为应该适用这个问题。

<?php
$file = 'data.csv';
$name = $_REQUEST['name'];
$attendance = $_REQUEST['attendance'];
$email = $_REQUEST['email'];
$additional = array($attendance,$name,$email);

非常感谢。也愿意为解决方案提供赏金。

1 个答案:

答案 0 :(得分:0)

试试这个

<input type="radio" name="attendance" value="Yes" class="attendance" />
<label>Yes</label>
<input type="radio" name="attendance" value="No" class="attendance" />
<label>No</label>

<script>
    var attendance
    $(".attendance").each(function()
    {
        if (this.checked == true)
        {
            attendance = this.value
            break
        }
    });
</script>