主题:jsp用户登录注册
congjitongID
[专家分:0] 发布于 2006-12-20 10:55:00
我想用JSP做一个用户登录注册的版面,要求用户名不能相同,用到Oracle
部要求功能太强大,只要能完成以上功能就可以了,谢谢!
定有高分!
回复列表 (共6个回复)
沙发
yexin218 [专家分:4070] 发布于 2006-12-20 12:05:00
你这是叫别人写作业阿?
先自己写,出错让他人看看。
板凳
congjitongID [专家分:0] 发布于 2006-12-20 12:15:00
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="">
<label>姓名:
<input name="USERNAME" type="text" id="USERNAME">
</label>
<label></label>
</form>
<p>密码:
<input name="USERPWD" type="password" id="USERPWD">
</p>
<form name="form2" method="post" action="">
<label>姓别</label>
:
<label>
<input name="SEX" type="radio" value="男">
男</label>
<label>
<input name="SEX" type="radio" value="女">
女</label>
</form>
<p>
<label>血型</label>
:
<label>
<input type="radio" name="BLOOD" value="O">
O</label>
<label>
<input type="radio" name="BLOOD" value="A">
A</label>
<label>
<input type="radio" name="BLOOD" value="B">
B </label>
<label>
<input type="radio" name="BLOOD" value="AB">
AB</label>
</p>
<form name="form3" method="post" action="">
<label></label>
性格 :
<label>
<input type="checkbox" name="CHATACTER" value="checkbox">
热情大方</label>
<label>
<input name="CHATACTER" type="checkbox" id="CHATACTER" value="checkbox">
温柔体贴</label>
<label>
<input name="CHATACTER" type="checkbox" id="CHATACTER" value="checkbox">
多情善感</label>
</form>
<form name="form4" method="post" action="">
<label>简介:
<textarea name="MEMO" rows="10" wrap="off" id="MEMO"></textarea>
</label>
</form>
<form name="form5" method="post" action="">
<label>城市:
<select name="CITY">
<option>天津市</option>
<option>北京市</option>
<option>大连市</option>
</select>
</label>
</form>
<form name="form6" method="post" action="handle.jsp">
<label>
<input type="submit" name="Submit" value="提交">
</label>
<label>
<input type="reset" name="Submit2" value="重置">
</label>
</form>
<p> </p>
<p> </p>
<%
request.setCharacterEncoding("GB2312");
String strUserName = request.getParameter("USERNAME");
String strUserPWD = request.getParameter("USERPWD");
String strUserSex = request.getParameter("SEX");
String strUserBlood = request.getParameter("BLOOD");
String strUserChar = request.getParameter("CHATACTER");
String strUserMemo = request.getParameter("MEMO");
String strUserCity = request.getParameter("CITY");
String serverName = "210.30.12.12";
ResultSet rs = connBean.executeQuery("select *from person='"+strUserName+'"");
if(re.next()){
out.println("<script language='javascript'>alert('该用户已存在,请重新注册!');window.location. href='imput.htm';</script>");
}
else
{
String sql = "Insert into person values(?,?,?,?,?,?,?)";
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@"+serverName+":1521:CONG";
Connection conn=DriverManager.getConnection(url,"system","system");
PreparedStatement stmt=conn.prepareStatement( sql );
stmt.setString(1,strUserName);
stmt.setString(2,strUserPWD);
stmt.setString(3,strUserSex);
stmt.setString(4,strUserBlood);
stmt.setString(5,strUserChar);
stmt.setString(6,strUserMemo);
stmt.setString(7,strUserCity);
stmt.executeUpdate();
stmt.close();
conn.close();
}catch(Exception e){
out.print(e);}
}
%>
</body>
</html>
这是我作的不知道哪里错了,麻烦了!
3 楼
yexin218 [专家分:4070] 发布于 2006-12-20 13:18:00
ResultSet rs = connBean.executeQuery("select *from person='"+strUserName+'"");
改成:ResultSet rs = connBean.executeQuery("select * from person='"+strUserName+"'");
看看
4 楼
congjitongID [专家分:0] 发布于 2006-12-21 07:43:00
呵呵,不好意思,一个人每个题目不能被评50分以上,要不我都给你拼30分了,谢谢!
5 楼
yexin218 [专家分:4070] 发布于 2006-12-21 12:00:00
呵呵,楼主很幽默
6 楼
adler [专家分:890] 发布于 2006-12-25 22:38:00
迷糊啊,为什么,我看了这么多学jsp的,喜欢将业务层的东西挪到试图层来处理,感觉有点jsp页面的负担太大了,安全性也不高??
我来回复