急问:输入用户的ID,点击“登录”后,显示的是用户名!
如题!页面登录时,用户输入自己的ID,登录成功后,显示的是用户名!
初学的,好多不懂的地方!请大家帮忙!
我是这样想的:首先有个表,里面有userid,username两项!(比较简单)
然后,做一login.jsp页面,这个页面很简单了,
<html>
<head>
<title>login</title>
</head>
<body>
<form action="login_result.jsp" method="POST" name="form1" onsubmit="return check()">
<table cellspacing="0" cellpadding="2" width="760" align="center" border="0" id="table1">
<tbody>
<tr>
<td height="35" width="346" align="right">账 号:</td>
<td height="37" align="left"><input type="text" name="userid" size="20" /></td>
</tr>
<tr>
<td height="35" width="346" align="right"></td>
<td height="37" align="left"> <input type="submit" value="提交" name="B1" /> <input type="reset" value="重置" name="B2" /></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
再有,一login_result.jsp,这页判断的条件我就不会写了,
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%
String username=request.getParameter("username");
String userid=request.getParameter("userid");
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)}; DBQ=E:/userdb.mdb";
Class.forName(driver);
Connection conn=DriverManager.getConnection(url,"","");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select userid from userinfo where *******请教部分);
if(rs.next()){
conn.close(};
out.println("username",username);
}
%>
谁帮我一下呗!