⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 register2.jsp

📁 网站的实例
💻 JSP
字号:
<%@ include file="data.jsp"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>register</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<jsp:useBean id="check" class="ebs.check" scope="page"/>
<%
//获取表单数据
String user_name=request.getParameter("u_nickname");
String pass=request.getParameter("u_pw");
String repass=request.getParameter("ru_pw");
String question=request.getParameter("u_question");
String answer=request.getParameter("u_answer");
String true_name=request.getParameter("u_turename");
//String id_card=request.getParameter("u_idcard");
String birth_y=request.getParameter("year");
String birth_m=request.getParameter("month");
String birth_d=request.getParameter("date");
String email=request.getParameter("u_email");
String tel=request.getParameter("u_tel");
//String mobile=request.getParameter("u_mobile");
String address=request.getParameter("u_address");
String post_zip=request.getParameter("u_postzip");
String province=request.getParameter("u_province");
String education=request.getParameter("u_education");
String employment=request.getParameter("u_employment");
String intro=request.getParameter("u_intro"); 

question=new String(question.getBytes("8859_1"),"GB2312"); 
answer=new String(answer.getBytes("8859_1"),"GB2312"); 
true_name=new String(true_name.getBytes("8859_1"),"GB2312"); 
address=new String(address.getBytes("8859_1"),"GB2312"); 
education=new String(education.getBytes("8859_1"),"GB2312"); 
employment=new String(employment.getBytes("8859_1"),"GB2312"); 
intro=new String(intro.getBytes("8859_1"),"GB2312"); 
province=new String(province.getBytes("8859_1"),"GB2312"); 

//检查数据的合法性
if(!check.check_user(user_name))
out.print("<font color=red>USERNAME ERROR!</font>--username can only be letter,numbers and _ , lengths is 3-20<br>");
if(!check.check_user_have(user_name))
out.print("<font color=red>Username already exist!</font><br>");
else if(!check.check_pass(pass,repass))
out.print("<font color=red>Code error!</font>--code can't be empty,length is 5-20 and twice must be same<br>");
else if(!check.check_blank(question))
out.print("<font color=red>Code question can't be empty!</font><br>");
else if(!check.check_blank(answer))
out.print("<font color=red>The answer can't be empty!</font><br>");
else if(!check.check_blank(true_name))
out.print("<font color=red>Truename can't be empty!</font><br>");
//else if(!check.check_idcard(id_card))
//out.print("<font color=red>Idcardnumber can't be empty!</font>---Plaeas fill in 15 to 18 idcardnumber<br>");
else if(!check.check_email(email))
out.print("<font color=red>Email error!</font>");
else if(!check.check_blank(address))
out.print("<font color=red>Please fill in your eaddress!</font><br>");
else if(!check.check_postzip(post_zip))
out.print("<font color=red>zipcode error!</font><br>");
else
{
	//将数据写入数据库
	String sql="insert into USER_INFO(user_pw,user_name,user_truename,user_question,user_answer,user_birth_y,user_birth_m,user_birth_d,user_email,user_phone,user_address,user_zip,user_province,user_education,user_employee,user_intor,user_login)values('"+pass+"','"+user_name+"','"+true_name+"','"+question+"','"+answer+"','"+birth_y+"','"+birth_m+"','"+birth_d+"','"+email+"','"+tel+"','"+address+"','"+post_zip+"','"+province+"','"+education+"','"+employment+"','"+intro+"',0)";
	try{
	Stmt.executeUpdate(sql);
	out.print("register successful!<a href='index.jsp' class='link'>Return Homepage</a>");}
	catch(SQLException e){out.print(e);}
}
Stmt.close();
Conn.close();
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -