HTML - 形式表现得很奇怪。不重定向到URL并使用GET而不是POST

时间:2014-04-27 08:08:00

标签: php html forms post

我是CS学生,我在不到24小时就有一个DB项目!这真烦人,因为我只需要表单来访问我的数据库。无论如何,我有这种形式完美的工作,而第二种形式不起作用。第二个表单不是发布和指向正确的URL,而是使用URL中的变量重新加载当前页面。有人有什么想法吗?

<form role="form" method="post" action="../controller/AddPerson.php">
    <div class="box-body">
        <div class="form-group">
            <label for="newReservationFirstName"> First name</label>
            <input type="text" class="form-control" name="newReservationFirstName" placeholder="Enter first name">
            <label for="newReservationLastName"> Last name</label>
            <input type="text" class="form-control" name="newReservationLastName" placeholder="Enter last name">
            <label for="newReservationPhoneNumber"> Phone Number</label>
            <div class="input-group">
                <div class="input-group-addon">
                    <i class="fa fa-phone"></i>
                </div>
                <input type="text" class="form-control" name="newReservationPhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
            </div><!-- /.input group -->

            <label for="newReservationStreetAddress"> Street Address</label>
            <input type="text" class="form-control" name="newReservationStreetAddress" placeholder="Enter street address">
            <label for="newReservationCity"> City</label>
            <input type="text" class="form-control" name="newReservationCity" placeholder="Enter city">
            <label for="newReservationState"> State</label>
            <select class="form-control" name="newReservationState">
                    <?php
                    $result = getTableOrderBy('States','stateName');
                    while($row = mysql_fetch_array($result)) {
                    echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
                    } ?>
            </select>
            <label for="newReservationZip"> Zip Code</label>
            <input type="text" class="form-control" name="newReservationZip" placeholder="Enter zipcode">
        </div>
        <button type="submit" class="btn btn-success btn-lg">Add New Customer</button>
    </div>
</form>

这是无法正常工作的表单,服务器上都存在这两个页面:

<form role="form" method="post" action="../controller/AddEmployee.php">
    <div class="box-body">
        <div class="form-group">
            <label for="newEmployeeFirstName"> First name</label>
            <input type="text" class="form-control" name="newEmployeeFirstName" placeholder="Enter first name">
            <label for="newEmployeeLastName"> Last name</label>
            <input type="text" class="form-control" name="newEmployeeLastName" placeholder="Enter last name">
            <label for="newEmployeePhoneNumber"> Phone Number</label>
            <div class="input-group">
                <div class="input-group-addon">
                    <i class="fa fa-phone"></i>
                </div>
                <input type="text" class="form-control" name="newEmployeePhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
            </div><!-- /.input group -->

            <label for="newEmployeeStreetAddress"> Street Address</label>
            <input type="text" class="form-control" name="newEmployeeStreetAddress" placeholder="Enter street address">
            <label for="newEmployeeCity"> City</label>
            <input type="text" class="form-control" name="newEmployeeCity" placeholder="Enter city">
            <label for="newEmployeeState"> State</label>
            <select class="form-control" name="newEmployeeState">
                    <?php
                    $result = getTableOrderBy('States','stateName');
                    while($row = mysql_fetch_array($result)) {
                    echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
                    } ?>
            </select>
            <label for="newEmployeeZip"> Zip Code</label>
            <input type="text" class="form-control" name="newEmployeeZip" placeholder="Enter zipcode">
            <p></p>
            <p></p>
            <label for="newEmployeeFirstName"> Account Username</label>
            <input type="text" class="form-control" name="newEmployeeUsername" placeholder="Enter username">
            <label for="newEmployeeLastName"> Account Password</label>
            <input type="text" class="form-control" name="newEmployeePassword" placeholder="Enter password">
            <label for="newEmployeePhoneNumber"> Social Security Number</label>
            <input type="text" class="form-control" name="newEmployeeSocial" placeholder="Enter SSN">
            <div class="form-group" name="newEmployeePrivileges">
                <br>
                Privileges :
                <select name="newEmployeePrivileges">
                <option value="admin">Admin</option>
                <option value="admin">Non-Admin</option>
                </select>
            </div>
            <button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
        </div>
    </div>
</form>

---------------------------------- EDIT ------------ ----------------------------------

我尝试在一些额外的空间上创建另一个非常简单的形式,但它仍然无效。我不知道是什么导致它这样做。

                <form method="post" action="post" action="../controller/AddEmployee.php">
                        <button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
                </form>

1 个答案:

答案 0 :(得分:0)

可能是您用于提交表单的按钮标记导致其行为异常。尝试更换按钮标记以获取输入。所以:

<form method="post" enctype="multipart/form-data" action="../controller/AddEmployee.php">
     <input type="submit" class="btn btn-success btn-lg" name="submit" >Add New Employee</input>
</form>

另外,我注意到你已经包含了两个&#39;动作&#39;示例表单中的属性: - )