//首页
<%@ 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>
<base href="<%=basePath%>">
<title>index.jsp</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<BODY>
<TR>
<TD align="center" bgcolor="#CCCC99">
访客留言板
</TD>
</TR>
<TR>
<FORM method="get" action="addMessage.jsp">
<table>
<tr>
<TD bgcolor="#CCCC99">
姓名:
</TD>
<TD bgcolor="#CCCC99">
<INPUT type="text" name="name" size="25">
</TD>
<TD bgcolor="#CCCC99">
E-mail:
</TD>
<TD bgcolor="#CCCC99">
<INPUT type="text" name="email" size="25">
</TD>
<TD bgcolor="#CCCC99">
主题:
</TD>
<TD bgcolor="#CCCC99">
<INPUT type="text" name="title" size="25">
</TD>
</tr>
<br>
<tr>
<TD valign="top" bgcolor="#CCCC99">
留言:
</TD>
<TD>
<TEXTAREA name="content" rows="7" cols="25"></TEXTAREA>
</TD>
</tr>
<TD colspan="3">
<tr>
<TD align="center" bgcolor="#CCCC99">
<INPUT type="submit" value="提交留言">
</TD>
<TD align="center" bgcolor="#CCCC99">
<A href="viewyh.jsp"><FONT size="2">查看留言</FONT></A>
</TD>
<TD align="center" bgcolor="#CCCC99">
<INPUT type="reset" value="重新填写">
</TD>
</tr>
<hr>
</table>
</form>
<hr>
<br>
<form method="GET" action="login.jsp">
<TABLE>
<P align="center" bgcolor="#CCCC99">
管理员登陆
</P>
<form method="post" action="login.jsp">
<TD>
用户名
</TD>
<TD bgcolor="#cccc99">
<input type="text" name="userId" size=25>
</TD>
<TD bgcolor="#cccc99">
密码:
</TD>
<TD bgcolor="#cccc99">
<input type="password" name="password" size=25>
</TD>
<TD align="center" bgcolor="#cccc99">
<input type="submit" value="登陆">
</TD>
<TD align="center" bgcolor="#cccc99">
<input type="reset" value="重填">
</TD>
</TABLE>
</form>
</body>
</html>
//验证用户名和密码
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.microsoft.jdbc.sqlserver.SQLServerDriver"%>
<%@ page import="java.lang.*"%>
<%@ page contentType="text/html; charset=gb2312" %>
<%
request.setCharacterEncoding("gb2312");
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev";
String USER="sa";
String PWD="123";
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
//????????
String id=request.getParameter("userId");
String psw=request.getParameter("password");
//?????
Class.forName(CLASSFORNAME);
Connection con = DriverManager.getConnection(SERVANDDB,USER,PWD);
Statement statement=con.createStatement();
String isCorrect="select * from user_info where userId='" + id + "' and password='" + psw + "'";
ResultSet result=statement.executeQuery(isCorrect);
session.setAttribute("isLog",new String("0"));
if(!result.next())
{
response.sendRedirect("index.jsp");//??????????????
result.close();
statement.close();
con.close();
}
//??????????????????
else
{
//???????session????
session.setAttribute("name",result.getString("name"));
session.setAttribute("id",result.getString("userId"));
session.setAttribute("email",result.getString("email"));
session.setAttribute("fav",result.getString("fanvcategory"));
session.setAttribute("userType",new Integer(result.getInt("userType")));
session.setAttribute("re","0");
System.out.println(session.getAttribute("userType"));
session.setAttribute("isLog",new String("1"));
int count=result.getInt("userLogCount");
session.setAttribute("userLogCount",new Integer(count));
count++;
session.setAttribute("userLastLogTime",result.getString("userLastLogTime"));
java.util.Date time1=new java.util.Date();//????????
String sqltime=new Timestamp(time1.getTime()).toString();//????????sql server???????
//???????
statement.execute("update user_info set userLogCount="+count+",userLastLogTime