register.jsp

来自「这是一个web数据库(运用jsp技术)的课设项目(教师科研信息管理系统),题目和」· JSP 代码 · 共 49 行

JSP
49
字号
<%@ page session="true"%>
<%@ page contentType="text/html;charset=gb2312" %>
<HTML>
 <head><title>register</title></head>
	<body bgcolor="#ffffff">
		<br>
		<br>
		<h1 align="center"><font color="00ff00" size=5>教师科研信息管理系统</font></h1>
		<hr color="#ff8000">
		<p>
		<center>
		<font color="FF00FF" size=4>注  册</font>
<%@ page language="java" import="java.sql.*,javax.sql.*;" %>
	[<a href="login.html" target=3>返回</a>]
	<%
	String name=request.getParameter("name");
	String pwd1=request.getParameter("pwd1");
	String pwd2=request.getParameter("pwd2");
	//out.println("<hr>"+name+"<hr>");

	
	String jdbcDriver="com.mysql.jdbc.Driver";
	String jdbcURL="jdbc:mysql://localhost:3306/teacher";
	try{
		Class.forName(jdbcDriver);
		Connection con=DriverManager.getConnection(jdbcURL,"root","000000");
		Statement stmt=con.createStatement();
		
		if (pwd1.equals(pwd2)){
			stmt.executeUpdate("insert into teacher values('"+name+"','"+pwd1+"')");
%>

<hr><center>注册成功!</center><hr>

	<%}else{}
		stmt.close();
		con.close();
		System.out.println("注册成功!");
	}catch(ClassNotFoundException e){
		System.out.println("未找到要加载的驱动类");
	}catch(SQLException e){
		System.out.println("SQL错误提示:"+e);
	}
%>
 </BODY>
</HTML>


⌨️ 快捷键说明

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