<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>
1 回答
元芳怎么了
TA贡献1798条经验 获得超7个赞
不要忘记添加method具有以下值的属性post:
<form name="formLogin" action="path/to/yourfile/loginLog.php" method="post">
<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>
- 1 回答
- 0 关注
- 74 浏览
添加回答
举报
0/150
提交
取消