<div id="background">
<div class="form-group">
<label for="usr" style="position:fixed;margin-top:180px;margin-left:900px;"><u>Account ID</u>:</label>
<input type="text" placeholder="Enter your ID in here" class="form-control" id="usr" style="position:absolute;width:350px;margin-top:205px;margin-left:900px;">
</div>
<div class="form-group">
<label for="pwd" style="position:fixed;margin-top:230px;margin-left:900px;"><u>PIN</u>:</label>
<input type="password" placeholder="Enter your PIN in here" class="form-control" id="pwd" style="position:absolute;width:350px;margin-top:255px;margin-left:900px;">
<button type="submit" onClick="process_Login()" class="btn btn-default" style="font-weight:bold;font-family:Tahoma, Geneva, sans-serif;position:fixed;margin-left:1040px;margin-top:310px;width:100px;">Login</button>
<button type="submit" class="btn btn-default" style="font-weight:bold;font-family:Tahoma, Geneva, sans-serif;position:absolute;margin-left:1150px;margin-top:310px;width:100px;">Sign Up</button>
</div>
</div>
我在使用这段代码时遇到了一些问题,我正在 Web 中制作 ATM 视觉效果。我想将数据从 HTML 文件传输到 PHP 文件,我知道我必须使用“表单”,但我不知道在这种情况下如何使用它,我还使用“脚本”来解决用户输入错误值的问题。
<script>
function process_Login() {
var c = document.getElementById("usr").value;
var d = document.getElementById("pwd").value;
if (c.length == 0) {
alert("ERROR: Your ID account is NULL");
} else if (isNaN(c)) {
alert("ERROR: Your ID must be number");
}
}
</script>
我该怎么做才能修复它?
最佳答案
如果您正在制作一个表单,您会将其发布到您的 PHP 脚本中。 您的输入需要有一个名称属性,即
<form action="myPHPLogin.php" method="post">
<input type="text" placeholder="Do this.." name="username">
<button type="submit">submit</button>
</form>
在您的 PHP 脚本中,您可以使用 $_POST['username'] 等访问您的字段。
关于javascript - 在这种情况下,如何将数据从 html 传输到 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36758461/