我在所有字段上输入数据后,PHP页面回显的“缺少字段”

时间:2019-01-04 19:41:57

标签: php html sql forms session

我在我的网站上有一张注册表,当它转到php页面时,该页面将用户数据保存在数据库中,它说即使我都填写了所有字段,仍然缺少字段。


表单代码:

__call__

php代码:

<form action="registo.php" method="post">

          <div class="field-wrap">
            <label>
              Nome de utilizador<span class="req">*</span>
            </label>
            <input name="username" type="text"required autocomplete="off"/>
          </div>

          <div class="top-row">
            <div class="field-wrap">
              <label>
                Palavra-passe<span class="req">*</span>
              </label>
              <input name="password" type="text" required autocomplete="off" />
            </div>

            <div class="field-wrap">
              <label>
                Confirmar<span class="req">*</span>
              </label>
              <input name="password2" type="password"required autocomplete="off"/>
            </div>
          </div>

          <div class="field-wrap">
            <label>
              Nome completo<span class="req">*</span>
            </label>
            <input name="nome" type="text"required autocomplete="off"/>
          </div>

            <div class="top-row">
            <div class="field-wrap">
              <label>
                Data Nascimento<span class="req">*</span>
              </label>
              <input name="dataNas" type="text" required autocomplete="off" />
            </div>

            <div class="field-wrap">
              <label>
                Contacto<span class="req">*</span>
              </label>
              <input name="telemovel" type="text"required autocomplete="off"/>
            </div>
          </div>

          <div class="field-wrap">
            <label>
              Email<span class="req">*</span>
            </label>
            <input type="email"required autocomplete="off"/>
          </div>

          <button name="email" type="submit" class="button button-block"/>Registar</button>

           <script type="text/javascript">

           </script>

          </form>

原本打算保存数据并转到mercadorias.html

表格的

codepen代码: https://codepen.io/joanaf/pen/yGKVgv

codepen for php: https://codepen.io/joanaf/pen/PXRbpG

1 个答案:

答案 0 :(得分:-1)

您已为按钮的name属性指定了“ email”的值,我确定最初的意图是将其作为email字段的name属性的值

下面是带有建议的更正的演示:

当前错误状态

<div class="field-wrap">
  <label>
    Email<span class="req">*</span>
   </label>
   <input type="email"required autocomplete="off"/>
</div>

<button name="email" type="submit" class="button button-block"/>Registar</button>

当前错误状态

<div class="field-wrap">
  <label>
    Email<span class="req">*</span>
   </label>
   <input type="email" name="email" required autocomplete="off"/>
</div>

<button type="submit" class="button button-block"/>Registar</button>