显示提交的数据到日志时出现问题

<script>

function login() {

  var userN = document.getElementById("userN").value;

  var pin = document.getElementById("pin").value;


  if (userN == "") {

    alert("User name not entered");

    document.getElementById("userN").focus();

    }

    else if (pin == "") {

      alert("PIN Number not entered");

      document.getElementById("pin").focus();

      }

      else {

        var userAccount = "User Name:" + userN + "\n" +

          "Pin:" + pin;

        alert("userAccount");

      }

    }

  </script>

</head>


<body>

  <h2>Please enter your User Name and PIN:</h2>

  <form name="formLogin" action="">

    <action="loginLog.php" method="post">

    <p><label for="userN">User Name: </label>

      <input type="text" name="userN" id="userN" size="20" maxlength="8" tabindex="1"></p>

    <p><label for="pin">PIN Number: </label>

      <input type="password" name="pin" id="pin" size="20" maxlength="8" tabindex="2"></p>


    <input type="submit" onclick="return login();" />

    <input type="reset" onclick="document.formLogin.userN.focus();" />

  </form>

我在使用 $_Post 捕获和回显以显示在登录页面上提交的数据时遇到问题。我不确定在登录页面上获取此数据以推送到 loginLog.php 我缺少什么


这是我的 loginLog.php 文件


<body>

Welcome

<?php

    echo $_POST["userN"];


?>


<?php

    echo $_POST["pin"];

?>



</body>


翻过高山走不出你
浏览 106回答 1
1回答

元芳怎么了

不要忘记添加method具有以下值的属性post:<form name="formLogin" action="path/to/yourfile/loginLog.php" method="post">&nbsp; &nbsp; <action="loginLog.php" method="post">&nbsp; &nbsp; <p><label for="userN">User Name: </label>&nbsp; &nbsp; &nbsp; <input type="text" name="userN" id="userN" size="20" maxlength="8" tabindex="1"></p>&nbsp; &nbsp; <p><label for="pin">PIN Number: </label>&nbsp; &nbsp; &nbsp; <input type="password" name="pin" id="pin" size="20" maxlength="8" tabindex="2"></p>&nbsp; &nbsp; <input type="submit" onclick="return login();" />&nbsp; &nbsp; <input type="reset" onclick="document.formLogin.userN.focus();" />&nbsp; </form>
打开App,查看更多内容
随时随地看视频慕课网APP