<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户注册</title>
</head>
<body>
<%
String strSql="";
String database_username="root";
String database_password="";
String url="jdbc:mysql://localhost/ch3?useUnicode=true&characterEncoding=gb2312";
try
{
Class.forName("org.gjt.mm.mysql.Driver");
Connection dbConn= DriverManager.getConnection(url,database_username,database_password);
Statement stmt=dbConn.createStatement();
ResultSet rs=null;
String s_UserName = request.getParameter("UserName");
strSql = "select * from users where UserName like '"+s_UserName+"'";
rs = stmt.executeQuery(strSql);
if(rs.next())
{
out.println("<h1 align=center>用户名<font color=red>"+s_UserName+"</font>已经存在!</h1>");
out.println("<div align=center><input type=button name=btn value=返回 onClick='window.history.go(-1)'></div>");
}
else
{
String s_UserPassword = request.getParameter("UserPassword");
String s_NickName = request.getParameter("NickName");
String s_Sex = request.getParameter("Sex");
String s_Email = request.getParameter("Email");
strSql = "insert into users (UserName,UserPassword,NickName,Sex,Email) values('"+s_UserName+"','"+s_UserPassword+"','"+s_NickName+"','"+s_Sex+"','"+s_Email+"')";
try