//index.jsp
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
登陸用戶登陸
用戶名: | |
密? 碼: |
注冊新用戶 |
//
Logon.jsp
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
登陸確認function BackWard()
{
history.back();
}
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
//"com.microsoft.sqlserver.jdbc.SQLServerDriver"要與驅動類名一樣
String url="jdbc:sqlserver://localhost:1433;databaseName=STUDENT";
//STUDENT為數據庫名
String user="sa";
String userpassword="123456";
Connection conn= DriverManager.getConnection(url,user,userpassword);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
boolean a;
String uid=request.getParameter("uid");
String password=request.getParameter("password");
String sql="select * from S where UID='"+uid+"' and Password='"+password+"'";
ResultSet rs=stmt.executeQuery(sql);
a=rs.next();
if(a==false)
{rs.close();
session.setAttribute("uid",uid);
%>
用戶名或密碼錯誤,請重新填寫!
else
{
rs.close();
%>
:)歡迎您
//Register1.jsp
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
注冊信息確認function backward()
{
history.back();
}
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
//"com.microsoft.sqlserver.jdbc.SQLServerDriver"要與驅動類名一樣
String url="jdbc:sqlserver://localhost:1433;databaseName=STUDENT";
//STUDENT為數據庫名
String user="sa";
String userpassword="123456";
Connection conn= DriverManager.getConnection(url,user,userpassword);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String uid=request.getParameter("uid");
String sql="select * from S where uid='"+uid+"'";
ResultSet rs=stmt.executeQuery(sql);
if(rs.next())
{
rs.close();
stmt.close();
conn.close();
%>
用戶名不能重名,請重新選擇!
else{
rs.close();
String username=request.getParameter("username");
String sex=request.getParameter("sex");
String password=request.getParameter("password");
%>
用 戶 名: | |
密??? 碼: | |
性??? 別: | |
真實姓名: |
//Register2.jsp
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
注冊確認Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
//"com.microsoft.sqlserver.jdbc.SQLServerDriver"要與驅動類名一樣
String url="jdbc:sqlserver://localhost:1433;databaseName=STUDENT";
//STUDENT為數據庫名
String user="sa";
String userpassword="123456";
Connection conn= DriverManager.getConnection(url,user,userpassword);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String uid=request.getParameter("uid");
String username=request.getParameter("username");
String sex=request.getParameter("sex");
String password=request.getParameter("password");
String sql="insert into S values('"+uid+"','"+username+"','"+sex+"','"+password+"')";
stmt.executeUpdate(sql);
%>
:祝賀您,注冊成功!
3秒后自動返回登陸窗口,如果你不想等待,可以點擊這里返回首頁
//Logoff.jsp
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
用戶注銷成功注銷!
5秒后自動返回首頁,如果你不想等待,可以點擊這里返回首頁
//Register.jsp
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
用戶注冊