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

📄 register_deal.jsp

📁 是一个自己做的在线阅读的jsp网站
💻 JSP
字号:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page import="java.sql.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'register_deal.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<%request.setCharacterEncoding("gb2312");
  Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
					.newInstance();
			String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bookshop";
			Connection conn = DriverManager.getConnection(url, "sa", "123");
			
  String username=request.getParameter("username");
  String password=request.getParameter("password");
  String email=request.getParameter("email");
  Statement st = conn.createStatement();
  ResultSet rs=st.executeQuery("select * from member where username='"+username+"'");
  
  session.putValue("Username",username);
  session.putValue("Password",password);
%>
<table width="100%" border="0" cellspacing="1" cellpadding="1" align="center">
<% if(rs.next()){%>
  <tr bgcolor="E0E0E0" valign="top"> 
    <td bgcolor="E0E0E0" align="center"><%out.println("用户名已存在,请重新注册");%></td>
  </tr>
  <tr bgcolor="E0E0E0" valign="top"> 
    <td bgcolor="E0E0E0"><div align="center">
        <input name="submit" type="button" value="确定" onClick="history.back(1);">
      </div></td>
  </tr>

<%}else{ String sql="Insert into member(username,psw,email) values('"+username+"','"+password+"','"+email+"')";
   int ret=0;
   ret=st.executeUpdate(sql);
   if(ret!=0){
%>
  <tr bgcolor="E0E0E0" valign="top"> 
    <td bgcolor="E0E0E0" align="center"><%out.println("恭喜您,注册成功");%></td>
  </tr>
  <tr bgcolor="E0E0E0" valign="top"> 
    <td bgcolor="E0E0E0"><div align="center">
        <input name="submit" type="button" value="回到主页" onClick="window.location.href='index.jsp';">
      </div></td>
  </tr>
           <%}
   else{%>
   <tr bgcolor="E0E0E0" valign="top"> 
    <td bgcolor="E0E0E0" align="center"><%out.println("用户注册失败");%></td>
  </tr>
  <tr bgcolor="E0E0E0" valign="top"> 
    <td bgcolor="E0E0E0"><div align="center">
        <input name="submit" type="button" value="确定" onClick="history.back(1);">
      </div></td>
  </tr>
     <%}}%>
</table>
</body>
</html>

⌨️ 快捷键说明

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