为什么我的动作属性不工作在下面的代码


why my action attribute is not working in the below code

    //Here i have mentioned one form and gave action in that.I also gave a button submit.Now when I click on the submit button, It the action given in the form is not perfoming.

<form action="submit.php" method="POST">
            <tbody>
                <tr id='addr0' data-id="0" class="hidden">
                <td data-name="loannum">
                  <input type="number" class="form-control" required>
                </td>
                <td data-name="name">
                  <input id="startdate" name="startdate" min="2016-01-01" max="2020-01-01" type="date" class="form-control">
                </td>
                <td data-name="name">
                    <input type="text" name='gname' placeholder='Group Name' class="form-control"  pattern="([A-z's]){2,}" required/>
                </td>
                <td data-name="desc">
                    <input type="number" placeholder='Batch Number' class="form-control" pattern="[0-9]{9}" required>
                </td>   
            </tr>
        </tbody>
    </table>
</div>
</div>
    <a id="add_row" class="btn btn-primary" style="background:#84ca71;color:#F44336;padding-bottom:24px;">Add Group</a>
//here we mentioned a button and when we click on it the action given in form should be performed
    <button class="btn btn-default" type="submit"  style="background:#cddc39;color:#F44336;padding:5px 30px 25px 20px;">submit</button>
    </form>

如果你真的在I also gave a button submit底部使用按钮,你也需要添加</form>关闭表单标签。

还要注意,这个输入将不返回任何内容:

<input type="number" class="form-control" required>

因为这里没有使用name属性。

还需要为Batch Number字段添加name属性。

<input type="number" placeholder='Batch Number' class="form-control" pattern="[0-9]{9}" required>

更新:

根据您的评论,您正在使用按钮和关闭表单标签,这意味着,这是纯粹的PHP问题,与表单操作无关。

你需要什么:

  • 您必须检查submit.php是否在同一根上可用,或者如果您只有一个文件,请将其留空<form action="">

  • 在submit.php文件中,您还需要检查post值,如print_r($_POST)检查您获得的内容并添加缺失的名称属性。

  • 最重要的部分是,不知道你是否使用isset(),你如何检查提交按钮是否设置与此输入:<button class="btn btn-default" type="submit" style="background:#cddc39;color:#F44336;padding:5px 30px 25px 20px;">

下面是正常工作的代码。form.html

<!DOCTYPE html>
<html>
<head>
<title>Popup Timepicker Demo Using AngularJS, Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta name="description"
    content="Popup Timepicker Demo Using AngularJS, Bootstrap.">
</head>
<body>
 <form action="submit.php" method="POST">
        <tbody>
            <tr id='addr0' data-id="0" class="hidden">
            <td data-name="loannum">
              <input type="number" name="name1" class="form-control" required>
            </td>
            <td data-name="name">
              <input id="startdate" name="startdate" min="2016-01-01" max="2020-01-01" type="date" class="form-control">
            </td>
            <td data-name="name">
                <input type="text" name='gname' placeholder='Group Name' class="form-control"  pattern="([A-z's]){2,}" required/>
            </td>
            <td data-name="desc">
                <input type="number" name="name2" placeholder='Batch Number' class="form-control" pattern="[0-9]{9}" required>
            </td>   
        </tr>
    </tbody>
</table>
    </div> </div> <a id="add_row" class="btn btn-primary" style="background:#84ca71;color:#F44336;padding-bottom:24px;‌​">Add Group</a> <button class="btn btn-default" type="submit" style="background:#cddc39;color:#F44336;padding:5px 30px 25px 20px;">submit</button> </form>
</body>
</html>

下面是submit.php代码,它位于form.html的同一个文件夹。

print_r($_POST);