reguser3.jsp
上传用户:xjrzjk
上传日期:2022-07-31
资源大小:1585k
文件大小:5k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GBK"%>
  2. <%@ page import="java.sql.*"%>
  3. <%
  4.   try{
  5.     //数据库连接
  6.     Class.forName("oracle.jdbc.driver.OracleDriver");
  7.     String strUrl = "jdbc:oracle:thin:@slight:1521:LOCAL";
  8.     String strUser = "eshop";
  9.     String strPassword = "eshop";
  10.     Connection con = DriverManager.getConnection(strUrl, strUser, strPassword);
  11.     Statement st = con.createStatement();
  12.     //判断是否有此用户
  13.     String strUid = request.getParameter("uid");
  14.     String strSql = "select * from RegUser where UserID='" + strUid + "'";
  15.     ResultSet rs = st.executeQuery(strSql);
  16.     if(rs.next()){
  17.       rs.close();
  18.       response.sendRedirect("loginsb.jsp");
  19.       return;
  20.     }
  21.     //准备用户注册数据
  22.     String strName = request.getParameter("name");
  23.     strName = new String(strName.getBytes("iso8859-1"),"gb2312");
  24.     String strSex = request.getParameter("sex").trim();
  25.     strSex = new String(strSex.getBytes("iso8859-1"),"gb2312");
  26.     String strPwd = request.getParameter("pwd").trim();
  27.     strPwd = new String(strPwd.getBytes("iso8859-1"),"gb2312");
  28.     String strQuestion = request.getParameter("question").trim();
  29.     strQuestion = new String(strQuestion.getBytes("iso8859-1"),"gb2312");
  30.     String strAnswer = request.getParameter("answer").trim();
  31.     strAnswer = new String(strAnswer.getBytes("iso8859-1"),"gb2312");
  32.     String strEmail = request.getParameter("email").trim();
  33.     String strPhone = request.getParameter("usephone").trim();
  34.     String strAddr = request.getParameter("haddr").trim();
  35.     strAddr = new String(strAddr.getBytes("iso8859-1"),"gb2312");
  36.     String strPostCode = request.getParameter("postcode").trim();
  37.     strSql = "insert into reguser(userid,name,pwd,sex,question,answer,email,usephone,haddr,postcode,regtime) values('"
  38.              + strUid + "','"
  39.              + strName + "','"
  40.              + strPwd + "','"
  41.              + strSex + "','"
  42.              + strQuestion + "','"
  43.              + strAnswer + "','"
  44.              + strEmail + "','"
  45.              + strPhone + "','"
  46.              + strAddr + "','"
  47.              + strPostCode + "',sysdate)";
  48. //    out.println(strSql);
  49.     st.executeQuery(strSql);
  50.     strSql = "select * from reguser where userid='" + strUid + "'";
  51. //    out.println(strSql);
  52.     rs = st.executeQuery(strSql);
  53. %>
  54. <head>
  55. <link rel="stylesheet" type="text/css" href="style.css">
  56. </head>
  57. <BODY bgColor=#ffffff>
  58. <DIV align=center>
  59. <TABLE cellSpacing=0 cellPadding=0 width=750>
  60.   <TBODY>
  61.   <TR>
  62.     <TD height=62>
  63.       <DIV align=center><BR>
  64. <%
  65.     if (rs.next()){
  66. %>
  67.  <TABLE class=main cellSpacing=1 cellPadding=2 width=602 bgColor=#0099CC height="280">
  68.         <TBODY>
  69.         <TR>
  70.           <TD colSpan=2 width="592" height="18">
  71.             <p align="center"><FONT
  72.             color=#ffffff><B>您的注册信息</B></FONT></p>
  73.           </TD></TR>
  74.         <TR>
  75.           <TD width=129 bgColor=#ffffff align="right" height="25">您的会员帐号: </TD>
  76.           <TD bgColor=#ffffff width="455" height="25"><%=rs.getString("userid")%> </TD></TR>
  77.         <TR>
  78.           <TD width=129 bgColor=#ffffff align="right" height="25">您的姓名:</TD>
  79.           <TD bgColor=#ffffff width="455" height="25"><%=rs.getString("name")%> </TD></TR>
  80.         <TR>
  81.           <TD width=129 bgColor=#ffffff align="right" height="25"><FONT color=#000000>性别:</FONT></TD>
  82.           <TD bgColor=#ffffff width="455" height="25"><%=rs.getString("sex")%>  </TD></TR>
  83.         <TR>
  84.           <TD width=129 bgColor=#ffffff align="right" height="26">密码:</TD>
  85.           <TD bgColor=#ffffff width="455" height="26">(保密)</TD></TR>
  86.         <TR>
  87.           <TD width=129 bgColor=#ffffff align="right" height="26">密码提问:</TD>
  88.           <TD bgColor=#ffffff width="455" height="26"><%=rs.getString("question")%> </TD></TR>
  89.         <TR>
  90.           <TD width=129 bgColor=#ffffff align="right" height="26">密码答案:</TD>
  91.           <TD bgColor=#ffffff width="455" height="26"><%=rs.getString("answer")%>  </TD></TR>
  92.         <TR>
  93.           <TD width=129 bgColor=#ffffff align="right" height="26">E-MAIL:</TD>
  94.           <TD bgColor=#ffffff width="455" height="26"><%=rs.getString("email")%>  </TD></TR>
  95.         <TR>
  96.           <TD width=129 bgColor=#ffffff align="right" height="26">常用电话:</TD>
  97.           <TD bgColor=#ffffff width="455" height="26"><%=rs.getString("usephone")%>  </TD></TR>
  98.         <TR>
  99.           <TD width=129 bgColor=#ffffff align="right" height="26">收货地址:</TD>
  100.           <TD bgColor=#ffffff width="455" height="26"><%=rs.getString("haddr")%> 
  101.         </TD></TR>
  102.         <TR>
  103.           <TD width=129 bgColor=#ffffff align="right" height="26">邮编:</TD>
  104.           <TD bgColor=#ffffff width="455" height="26"><%=rs.getString("postcode")%> 
  105.         </TD></TR>
  106.         </TBODY></TABLE>
  107.       <BR>      <input type="button" value="进入商城" name="B4" onclick="window.location.href='index.jsp';">
  108. </DIV></TD></TR></TBODY></TABLE>
  109. <%
  110.   }
  111. %>
  112. </DIV></BODY>
  113. <%
  114.   }catch(Exception e){
  115.     e.printStackTrace();
  116.   }
  117. %>