初始登录界面

最终效果:

实现目的:1.可以自己选择身份登入,左上角显示是第几个访问访客

                  2.可以选择是否记住密码

                  3.个人信息为超链接,点击即跳转到个人信息详细界面

                  4.点击登录按钮或者未输入账号密码而移开鼠标,会网站提醒即非空验证

                  5.所输入的账号和密码需要由数据库的数据支持,若无数据库的数据匹配上同样也会                         进行报错

代码:login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <script>
    <!--
     function isValid()
		{if (frmlogin.id.value == "") 
		  {alert("您必须完成账号的的输入!");
		   document.frmlogin.elements(0).focus();
		   return false;}
		 else
		   if (frmlogin.password.value == "") 
		  {alert("您必须完成密码的输入!");
		  document.frmlogin.elements(1).focus();
			return false;}
	else
		  frmlogin.submit();
	}
	 
	 function lost()
	    {if (frmlogin.id.value == "") 
	       {document.getElementById("ids").innerHTML="请输入账号!!"} 
	 else 
	     if(frmlogin.password.value == "")
	       {document.getElementById("pas").innerHTML="请输入密码!!"}
	}
	
	-->
	</script>
    <base href="<%=basePath%>">
    <title>用户登录</title>
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<%if(session.isNew())
	   {Integer number = (Integer)application.getAttribute("count");
	  if(number == null){
	  number = new Integer(1);
	  application.setAttribute("count", number);}
	  else 
	   {number = new Integer(number.intValue()+1);
	    application.setAttribute("count", number);
	    }}
	   
	   request.setCharacterEncoding("utf-8");
       String wang=request.getParameter("wang");
       if(wang != null && wang.equals("0"))
          {
          out.print("<p style='color: red;text-align: center;'>用户名或密码错误!!请检查并重新输入!!</p>");
          }%>
          
       <%Cookie[] cookie=request.getCookies();
       String username="";
       String password="";
       if(cookie != null && cookie.length>0)
       {
       for(Cookie c:cookie){
         if(c.getName().equals("username")){
           username=c.getValue();
           }
         if(c.getName().equals("password")){
           password=c.getValue();
           }
           }
           }%>

  </head>
  
   <body bgcolor="#FFFFF0">
    <p><font style="color: blue" size="5">您是第<%=(Integer)application.getAttribute("count")%>位访客</font></p>
    <center><b><font color="#FFD700" size="7" face="华文行楷" >学生课绩管理系统</font></b></center>
    <form action="loginforword.jsp" method="post" name="frmlogin">
    <table width="50%" height="200" border=1 bgcolor="#E6E6FA" align="center">
    <tr>
    <td align="right">
    <font color="#32CD32" size="5" face="华文行楷">用户选择</font>
    </td>
    <td align="left">
    <input name="kind" type="radio" value="student" checked>
    <font color="#32CD32" size="5" face="华文行楷">学生</font>
    <input type="radio" name="kind" value="teacher">
    <font color="#32CD32" size="5" face="华文行楷">教师</font>
    <input type="radio" name="kind" value="admin">
    <font color="#32CD32" size="5" face="华文行楷">管理员</font>
    </td></tr>
    <tr>
    <td align="right">
    <font color="#32CD32" size="5" face="华文行楷">登录名</font></td>
    <td align="left"><input name="id" type="text" maxlength="20" value="<%=username%>"/><span style="color: red" id="ids"></span></td>
    </tr>
     <tr>
    <td align="right" >
    <font color="#32CD32" size="5" face="华文行楷">密码</font></td>
    <td><input name="password" type="password" maxlength="8" onBlur="lost()" value="<%=password%>"/><span style="color: red" id="pas"></span></td>
    </tr>
    <tr><td colspan="2" align="center" ><input type="checkbox" name="isusecookie"/>是否记住账号密码</td></tr>
    <tr><td colspan="2" align="center">
    <input type="button" name="Submit" value="登录" onclick="isValid()">
    </td></tr>
    </table></form>
     <center><b><font color="#99FF33" size="2" >版权所有&copy:<a href="names.jsp">个人信息</a></font></b></center>
    </body>
</html>

 






  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我不是少爷.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值