简体   繁体   English

用HTML创建登录页面

[英]Creating a login page with HTML

I am trying to make a webpage where a user logs in and then once logged in, the page keeps track of the amount of time idle (not pressing keys or moving mouse). 我正在尝试制作一个用户登录的网页,然后登录后,该页面会跟踪空闲时间(不按键或移动鼠标)。 I have created both pages separately on codepen (see attached links). 我已经在Codepen上分别创建了两个页面(请参阅附件链接)。 However, I am not sure how to link the two so that the user can login and after waiting too long automatically log out. 但是,我不确定如何链接两者,以便用户可以登录,并且等待时间过长会自动注销。

Login page: http://codepen.io/joebob461/pen/MwdPzN 登录页面: http//codepen.io/joebob461/pen/MwdPzN

 //incomplete code sample from link
function check(form) { 
  if (form.userid.value == "myuserid" && form.pswrd.value == "mypswrd") {
     window.open('target.html') 
  } else {
  alert("Error Password or Username") 
 }
}

Idle Time page: http://codepen.io/joebob461/pen/BNeqvP 空闲时间页面: http : //codepen.io/joebob461/pen/BNeqvP

//incomplete code sample from link
#welcome {
  text-align: center;
}

You'll want to post the login form data back to the server to authenticate. 您需要将登录表单数据发回到服务器上进行身份验证。 The form post will redirect you to the second page with the idletimer javascript method. 表单发布将使用idletimer javascript方法将您重定向到第二页。

Once the idletimer code determines it is time to log the user out, you can use an ajax post back to your server to have the server do this. 一旦idletimer代码确定是时候注销用户了,您就可以使用ajax发布回您的服务器,以使服务器执行此操作。 You haven't specified what server framework you are using. 您尚未指定要使用的服务器框架。 However, in ASP.NET when using the ASP.NET Membership provider, you would just have the server call 但是,在ASP.NET中,使用ASP.NET Membership提供程序时,您只需要调用服务器即可

FormsAuthentication.Signout() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM