表格后不提交数据

时间:2018-04-17 20:01:31

标签: php html

表单有问题。在html中,我有一个表单,我想通过post,使用enctype multipart / form-data提交。 我在其他页面上多次使用该代码,但现在它不提交数据。不知道为什么。以下代码来自我的脚本(它不是全部,但是必要的部分)。

<?if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
  if (isset($_POST['login'])) {
    require 'login.php';
  }

  elseif (isset($_POST['register'])) {
    require 'register.php';
  }
}


?>
                <div id="login" role="form" class="r_form_elements" style="display:none">
                  <form class="form-signin bg-dark text-light" method="post" action="index2.php" enctype="multipart/form-data" autocomplete="off">


                        <div class="text-center mb-4">
                          <h1 class="h3 mb-3 font-weight-normal">Login</h1>

                        </div>

                        <div class="form-label-group mt-3">
                          <label for="inputEmail">Email address</label>
                          <input type="email" id="inputEmail" name="email" class="form-control" placeholder="Email address" required="" autofocus="">
                        </div>

                        <div class="form-label-group mt-3">
                          <label for="inputPassword">Password</label>
                          <input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required="">
                        </div>

                                <label for="lang" style="display:none" class="sr-only">longitude</label>
                                <input type="text" style="display:none" name="lang" id="lang" class="form-control" required autofocus>
                                <label for="lat" style="display:none" class="sr-only">latitude</label>
                                <input type="text" style="display:none" name="lat" id="lat" class="form-control" required>

                        <button value="Login" name="login" class="btn btn-lg btn-primary btn-block mt-3" type="submit">Sign in</button>
                        <p class="mt-5 mb-3 text-muted text-center">By signing in you agree to the <a href="tos">Terms of Service</a></p>
                  </form>
                </div>

这通常应该将数据提交到登录页面。但事实并非如此。没有任何反应或任何事情。好像浏览器无法识别提交按钮。

有人可以解释一下原因吗?我已经尝试了不同的立场,但它没有帮助。

提前致谢。

1 个答案:

答案 0 :(得分:3)

可能是因为你有两个

<input type="text" ... style="display:none" required>

因此,当您提交时,它会发现您所需的输入没有任何价值,因此它不会提交,并且由于您display: none您没有看到错误消息。

相关问题