【问题标题】:HTML Form Submit To SelfHTML 表单提交给自己
【发布时间】:2012-08-14 03:29:09
【问题描述】:

有人能告诉我为什么这不是屈服于自我吗?

我有以下设置:

<?php
     print_r($_POST);
?>

 <form name="bizLoginForm" method="post" action"" >
    <table id="loginTable">
        <tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr>
        <tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr>
    </table>
    <input type="Submit" value="Login" />
</form>

每次我单击提交按钮时,我都看不到 POST 数组中的任何内容。我完全忽略了哪些简单的事情?

谢谢!

【问题讨论】:

    标签: php html forms submit


    【解决方案1】:

    除了表单元素的action 属性中缺少等号之外。

    您的输入需要名称属性:

    <tr>
        <td>Username:</td>
        <td><input id="loginUsername" name="loginUsername" type="text" /></td>
    </tr>
    

    【讨论】:

      【解决方案2】:
       <form name="bizLoginForm" method="post" action"" >
      

      应该是

       <form name="bizLoginForm" method="post" action="" >
      

      缺少 = 符号。

      您还缺少输入标签中的 name 属性,因此请更改

      <input type="text" id="loginUsername" />
      

      <input type="password" id="loginPassword" />
      

      <input type="text" id="loginUsername" name="loginUsername" />
      

      <input type="password" id="loginPassword" name="loginPassword" />
      

      【讨论】:

      • :-) html 可能需要编译器?
      • 错误或未提交?
      • 啊,不喜欢提交中的大写“S”,但这似乎也没有让 POST 数组看到数据。
      • 请参阅以下有关为所有内容添加名称属性的建议。我实际上错过了。没有“名称”属性,没有数据会通过。
      • @sjobe:他缺少 name 属性。请参阅上面理查德的回答。
      【解决方案3】:
      • 您应该在 action 和 ""
      • 之间添加 等号
      • 还要为每个输入字段指定 name 属性。

      <?php
           print_r($_POST);
      ?>
      
       <form name="bizLoginForm" method="post" action="" >
          <table id="loginTable">
              <tr><td>Username:</td><td><input type="text" name="login" id="loginUsername" /></td></tr>
              <tr><td>Password:</td><td><input type="password" name="password" id="loginPassword" /></td></tr>
          </table>
          <input type="Submit" value="Login" /></form>
      

      【讨论】:

        【解决方案4】:

        试试这个

        <?php
           if(isset($_POST['submit_button']))
              print_r($_POST);
        ?>
        
        <form name="bizLoginForm" method="post" action"<?php echo $_SERVER['PHP_SELF']?>" >
          <table id="loginTable">
            <tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr>
            <tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr>
          </table>
          <input type="Submit" name="submit_button" value="Login" />
        </form>
        

        使用 .php 扩展名保存文件

        【讨论】:

          【解决方案5】:

          试试这个

          <?php
          if(isset($_GET["submitted"])){
              print_r($_POST["values"]);
          } else {
          ?>
           <form name="bizLoginForm" method="post" action="?submitted" >
              <table id="loginTable">
                  <tr><td>Username:</td><td><input type="text" name="values[]" id="loginUsername" /></td></tr>
                  <tr><td>Password:</td><td><input type="password" name="values[]" id="loginPassword" /></td></tr>
              </table>
              <input type="Submit" value="Login" />
          </form>
          <?php
          }
          ?>
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2012-11-11
            • 1970-01-01
            • 2014-05-26
            • 2011-08-15
            • 1970-01-01
            • 1970-01-01
            • 2016-11-12
            相关资源
            最近更新 更多