【问题标题】:Post-Form doesn't submit dataPost-Form 不提交数据
【发布时间】:2018-09-27 22:02:37
【问题描述】:

表单有问题。在 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>

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

有人可以解释原因吗?我已经尝试了不同的位置来确定,但它没有帮助。

提前致谢。

【问题讨论】:

  • 从隐藏标签和输入中删除所需

标签: php html


【解决方案1】:

可能是因为你有两个

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

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

【讨论】:

  • 是的,你是对的(SC92 也是如此)。在测试时,我经常从页面登录和注销,并且地理定位的使用部分不起作用。谢谢。
猜你喜欢
  • 2020-07-18
  • 2011-02-23
  • 2016-12-20
  • 1970-01-01
  • 2010-12-06
  • 2013-07-30
  • 1970-01-01
  • 1970-01-01
  • 2015-12-31
相关资源
最近更新 更多