PHP无法POST选择框值

时间:2014-07-05 11:15:51

标签: php jquery html post mysqli

我正在尝试从用户那里获取一些价值,然后我将这些值插入到我的数据库中,但我无法使用{{{{{{{{{ 1}}。

用户首先通过选择框选择内部类型,并根据此选择框的值,底部菜单通过jQuery更改(这就是为什么这些IENG349ReqCourses和IENG449ReqCourses $_POST被隐藏的原因< / em>的)。

但我无法在这些隐藏的div内获取等级选择框的值。其余的输入字段都可以,我可以获取它们的值并保存到我的数据库中。

HTML:

div

PHP:

<form id="intershipStage1Form" method="POST" action="form1.php">
    <div id="generalInfo">
        <center>
            <table>
                <tr>
                    <td colspan="2" valign="middle" align="center">
                        <label id="stuNameLabel">Student Full Name: <?php echo $_SESSION['username']; ?></label>
                    </td>
                </tr>
                <tr>
                    <td title="Your student number contains only numbers and should be 11 digits " valign="middle"><label id="stuNumberLabel">Student Number:</label></td>
                    <td><input id="stuNumberText" class="form1Text" type="text" name="stuNumberText" /></td>
                </tr>
                <tr>
                    <td title="A sample format: 3.16 and do not use comma(,)" valign="middle"><label id="stuGPALabel">Student GPA:</label></td>
                    <td><input id="stuGPAText" class="form1Text" type="text" name="stuGPAText" /></td>
                </tr>
                <tr>
                    <td title="Choose your academic advisor" valign="middle"><label id="stuAdvisorLabel">Student Advisor:</label></td>
                    <td align="center">
                        <select id="advisorSelectionBox" name="advisorSelectionBox">
                            <option value="">--select--</option>
                            <?php
                                $userType = "A";
                                $stmt = $db->prepare("SELECT * FROM users WHERE UserType = ?");
                                if($stmt == "false"){
                                    die('Query error !'.$db->error);  
                                }
                                $stmt->bind_param('s', $userType);
                                $stmt->execute();
                                $result = $stmt -> get_result();

                                while($advisor = $result ->fetch_array(MYSQLI_BOTH)){
                                    echo '<option value="'.$advisor["UserID"].'">'.$advisor['FirstName']." ".$advisor['LastName'].'</option>';
                                }
                            ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td title="Choose your current study year" valign="middle">
                        <label>Study Year:</label>
                    </td>
                    <td align="center">
                        <select id="studyYearBox" name="studyYearBox">
                            <option value="">--select--</option>
                            <option value="SOPHOMORE">SOPHOMORE</option>
                            <option value="JUNIOR">JUNIOR</option>
                            <option value="SENIOR">SENIOR</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td title="Choose your internship type before try to sent this form to your advisor" valign="middle">
                        <label>Internship Type:</label>
                    </td>
                    <td align="center">
                        <select id="intershipTypeBox" name="intershipTypeBox">
                            <option value="">--select--</option>
                            <option value="IENG349">IENG 349</option>
                            <option value="IENG449">IENG 449</option>
                        </select>
                    </td>
                </tr>
            </table>
        </center>
    </div>
    <div id="litleSpacer"></div>
    <div id="IENG349ReqCourses" class="reqCourses" hidden="true">
        <center>
            <table>
                <caption style="color:#f00;">Please select your grades</caption>
                <tr>
                    <td valign="middle">
                        <label>IENG 102 - Intro to IE:</label>
                    </td>
                    <td>
                        <select name="IENG102Grade">
                            <option value="">--select--</option>
                            <option value="A">A</option>
                            <option value="A-">A-</option>
                            <option value="B+">B+</option>
                            <option value="B">B</option>
                            <option value="B-">B-</option>
                        </select>
                    </td>
                </tr>
            </table>
        </center>
    </div>
    <div id="IENG449ReqCourses" class="reqCourses" hidden="true">
        <center>
            <table>
                <caption style="color:#f00;">Please select your grades</caption>
                    <tr>
                        <td valign="middle">
                            <label>IENG 312 - System Simulation:</label>
                        </td>
                        <td>
                            <select name="IENG312Grade">
                                <option value="">--select--</option>
                                <option value="A">A</option>
                                <option value="A-">A-</option>
                                <option value="B+">B+</option>
                                <option value="B">B</option>
                                <option value="B-">B-</option>
                            </select>
                        </td>
                    </tr>
            </table>
        </center>
    </div>
    <div id="litleSpacer"></div>
    <input id="sendButton" type="submit" name="sendButton" value="SEND FOR APPROVEMENT"/>
</form>

那么问题是什么呢?任何帮助都会受到欢迎!

2 个答案:

答案 0 :(得分:1)

您必须选择一个选项才能将其发布到服务器。 如果字段被隐藏且未选择任何选项,则服务器上将不会显示任何值。

答案 1 :(得分:0)

我建议您查看Live Http Headers中的示例,其中包含您发送的$ _POST日期。同样在你的脚本顶部放 var_dump($_POST);