当前页面: 开发资料首页 → JSP 专题 → 一种新的编程思路(下):附 bbs之register.jsp
摘要: java jsp sql
register.jsp
---------------------------------------------------------------------------------
<%@page contentType="text/html;charset=GBK" %>
<%@include file="head.jsp"%>
<%@include file="ntGBDP2002_Define.jsp" %>
<%
file://全局变量定义
globalTableName = "bbs_users";
parentKey = "BBS用户资料";
parentValue = "";
dbName = "mhoa";
%>
<%@include file="ntGBDP2002.jsp" %>
<%
String u = (String)requestHt.get("用户名");
if( u==null ) u="";
u = u.trim();
String errorString = "";
if( isPost && !nt.isDate((String)requestHt.get("date出生时间")) ){
errorString = "请填写正确的出生时间!";
}else if( isPost && !((String)requestHt.get("密码")).equals((String)requestHt.get("nouse确认密码")) ){
errorString = "请填写正确的密码!";
}else if( isPost && ( u==null || u.equals("") ) ){
errorString = "请填写用户名!";
}else if( isPost && isAdd && nt.executeQuery(dbName,"select * from "+ globalTableName +" where k='用户名' and v='"+u+"' ")>0 ){
errorString = "已经存在此用户名!";
}
if( isPost && !errorString.equals("") )
{
out.println("<script>alert('"+ errorString +"');history.back();</script>");
return;
}
if( isAdd ){
requestHt.put("注册日期",(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new java.util.Date()) );
}
//
out.println( "
<head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="778" border="0" cellspacing="1" cellpadding="0" bgcolor="#345487" align="center">
<tr>
<td></td>
</tr>
</table>
<table width="778" border="0" cellspacing="1" cellpadding="0" bgcolor="#345487" align="center">
<tr>
<td bgcolor="#EEF2F7" height="20">
<form name="frm" method="post" action="<%= request.getRequestURI() %>">
<tr>
<td background="images/tile_back.gif" height="20"> </td>
</tr>
<tr>
<td bgcolor="#F5F8FD">
<table width="770" border="0" cellspacing="1" cellpadding="2" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#EEF1F6" width="311" align="right">用户名: </td>
<td bgcolor="#F5F8FD" width="448">
<input type="text" name="用户名" size="30" class="b">
<input type="hidden" name="<%= hasId?"id":"nouse" %>" value="<%= id %>" >
</td>
</tr>
<tr>
<td bgcolor="#EEF1F6" width="311" align="right"> 密 码: </td>
<td bgcolor="#F5F8FD" width="448">
<input type="<%
out.print("text");
else
out.print("password");
%>" name="密码" size="30" class="b">
</td>
</tr>
<tr>
<td bgcolor="#EEF1F6" width="311" align="right"> 确认密码: </td>
<td bgcolor="#F5F8FD" width="448">
<input type="password" name="nouse确认密码" size="30" class="b">
</td>
</tr>
<tr>
<td bgcolor="#EEF1F6" width="311" align="right"> E-mail: </td>
<td bgcolor="#F5F8FD" width="448">
<input type="text" name="E-mail" size="30" class="b">
</td>
</tr>
<tr>
<td bgcolor="#EEF1F6" width="311" align="right"> ICQ号码: </td>
<td bgcolor="#F5F8FD" width="448">
<input type="text" name="ICQ号码" size="30" class="b">
</td>
</tr>
<tr>
<td bgcolor="#EEF1F6" width="311" align="right"> OICQ号码: </td>
<td bgcolor="#F5F8FD" width="448">
<input type="text" name="OICQ号码" size="30" class="b">
</td>
</tr>
<tr>
<td bgcolor="#EEF1F6" width="311" align="right"> 出生时间: </td>
<td bgcolor="#F5F8FD" width="448">
<input type="text" name="date出生时间" size="18" class="b" value="1980-12-31">
</td>
</tr>
<tr>
<td bgcolor="#EEF1F6" width="311" align="right">
<%@include file="ntGBDP2002_Script.jsp" %>