html语言如何实现帐号密码登陆

html-css016

html语言如何实现帐号密码登陆,第1张

html可以使用表单进行的最简单的账号密码登录的页面设计,但是不具备判断账号密码正确性等逻辑的能力,这个需要后台语言处理反馈。

工具原料:编辑器、浏览器

1、使用form表单事件最简单的账号密码登录的数据提交,代码如下:

<!DOCTYPE html>

<html>

<body>

<form action="login.php">

用户名:<br>

<input type="text" name="firstname" value="请输入账号">

<br>

密码:<br>

<input type="text" name="lastname" value="请输入密码">

<br><br>

<input type="submit" value="Submit">

</form> 

</body>

</html>

2、点击提交数据将会提交给login.php进行处理,运行的结果如下:

以下代码可以实现静态网页的账号密码登录

<form method="post" action="***" name="form" onsubmit="checkpost()">

<label for="name">用户名:</label>

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

<br />

<label for="pw">密码:</label>

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

<br />

<input type="submit" value="提交" />

</form>

<script>

function checkpost(){

if(document.forms[5].name.value=="用户名"&&document.forms[5].pw.value==" 密码"){

window.location="跳转的地址"

}else{

alert("用户名或密码不正确!")

return false

}

}

</script>

<!DOCTYPE html><html lang="zh-CN"><head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>登录</title>

<link href="css/bootstrap.min.css" rel="stylesheet"></head><body><nav class="navbar navbar-default">

<div class="container-fluid">

<div class="navbar-header">

<a class="navbar-brand" href="./">jsp作业</a>

</div>

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

<ul class="nav navbar-nav navbar-right">

<li><a href="login.html">登录</a></li>

</ul>

</div>

</div></nav><div class="container">

<div class="row">

<div class="col-md-4">

</div>

<div class="col-md-4">

<form class="form-signin" target="submitFrame" method="post">

<h2 class="form-signin-heading">登录到jsp作业</h2>

<label for="inputEmail">Email</label>

<input type="email" id="inputEmail" class="form-control" placeholder="请输入Email" required autofocus><br>

<label for="inputPassword">密码</label>

<input type="password" id="inputPassword" class="form-control" placeholder="请输入密码" required>

<div class="checkbox">

<label>

<input type="checkbox" value="remember-me" checked="checked">记住密码</label>

</div>

<button type="submit" class="btn btn-primary" id="btn-login">登录</button>

<a href="reg.html" class="btn btn-default">注册</a>

</form>

<iframe style="display: none" name="submitFrame" src="about:blank"></iframe>

</div>

<div class="col-md-4">

</div>

</div>

<script src="js/jquery.min.js"></script></body></html>