jsp-公司管理系统-注册、会员管理等功能

源代码在线查看: adduser.jsp

软件大小: 76 K
上传用户: WJQ198926
关键词: jsp 管理系统
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				
				
				
				
				
				 
				
								//取得页面传递过来的用户资料
				request.setCharacterEncoding("gb2312");
				String username=request.getParameter("username");
				String password=request.getParameter("password");
				String realname=request.getParameter("realname");
				int sex=Integer.parseInt(request.getParameter("sex"));
				String age=request.getParameter("age");
				String region=request.getParameter("region");
				String email=request.getParameter("email");
				String education=request.getParameter("education");
				int marriage=Integer.parseInt(request.getParameter("marriage"));
				//获得当前注册日期
				Calendar nowCalendar=Calendar.getInstance();
				String regdate=nowCalendar.get(Calendar.YEAR)+"/"+
						(nowCalendar.get(Calendar.MONTH)+1)+"/"+
						nowCalendar.get(Calendar.DATE);
				//建立数据库连接并执行数据插入
				Connection conn=null;
				Statement stmt=null;
				try{
					Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
					conn=DriverManager.getConnection("jdbc:odbc:datasource_suit","sa","710318");
					stmt=conn.createStatement();
					String strSQL="insert into t_userInfo";
					strSQL+="(username,password,realname,sex,age,region,email,education,marriage,regdate) ";
					strSQL+="values(";
					strSQL+="'"+username+"',";
					strSQL+="'"+password+"',";
					strSQL+="'"+realname+"',";
					strSQL+=sex+",";
					strSQL+="'"+age+"',";
					strSQL+="'"+region+"',";
					strSQL+="'"+email+"',";
					strSQL+="'"+education+"',";
					strSQL+=marriage+",";
					strSQL+="'"+regdate+"')";
					//out.println(strSQL);
					stmt.executeUpdate(strSQL);
					stmt.close();
				}catch(Exception e){
					out.println(username+"用户注册失败");
				}finally{
					try{
						if(stmt!=null){
							stmt.close();
						}
						if(conn!=null){
							conn.close();
						}
					}catch(SQLException sqle){}
				}
				out.println(username+"用户已成功注册");
					
				%>			

相关资源