问题描述
<%@ page pageEncoding="gb2312"%><%@ page contentType="text/html; charset=gb2312" language="java" %><% request.setCharacterEncoding("gb2312");%><%@ page import="java.sql.*" errorPage="" %><%@ page import="javabean.*" %><%@ page import="java.util.Date" %><%@ page import="java.text.*" %><jsp:useBean id="sqlbean" class="javabean.mysqlbean" scope="page"></jsp:useBean><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>注册检查</title></head><body><%request.setCharacterEncoding("gb2312");String rand = (String)session.getAttribute("rand");String input=request.getParameter("rand");if (rand.equals(input)) { try{ request.setCharacterEncoding("gb2312"); String str_name=request.getParameter("username"); String sqlname="select * from tb_user where username='"+str_name+"'";//表名user ResultSet rsname=sqlbean.executeQuery(sqlname); if(rsname.next())//判断是否有雷同的数据存在,即判断是否有已注册的用户名。 { out.println("<script language='JavaScript'>alert('该用户名已经存在,请使用其他用户名!');window.location='index.jsp';</script>"); } else{ request.setCharacterEncoding("gb2312"); String str_datatime=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getDate()); String str_password=request.getParameter("password"); String str_password2=request.getParameter("password2"); String str_sex=request.getParameter("sex"); String str_email=request.getParameter("email"); String str_question=request.getParameter("question"); String str_answer=request.getParameter("answer"); String str_qq=request.getParmaeter("qq"); String str_words=request.getParameter("words"); String sqlinsert="insert into tb_user (username,password,sex,email,question,answer,qq,str_datatime,words) values('"+str_name+"','"+str_password+"','"+str_sex+"','"+str_email+"','"+str_question+"','"+str_answer+"','"+str_qq+"',"+str_datatime+"','"+str_words+"')"; out.println("<script language='JavaScript'>alert('恭喜,注册成功!');window.location='index.jsp';</script>");} sqlbean.close(); }catch(Exception ex){ out.println("<script language='JavaScript'>alert('注册失败!请重新注册。');window.location='index.jsp';</script>"); } }else{ out.println("<script language='JavaScript'>alert('验证码输入错误,请重新输入!');window.location='index.jsp';</script>"); }%></body></html><%@ page pageEncoding="gb2312"%><%@ page contentType="text/html; charset=gb2312" language="java" %><% request.setCharacterEncoding("GB2312");%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>用户注册</title> <style>body { background: #Ffffff; font-size:9pt; } A:link {text-decoration: none; color: #0066ff; font-size:9pt } A:visited { text-decoration: none; color: #1e90ff; font-size:9pt }A:hover { text-decoration: underline; COLOR: #006699; font-size:9pt }table{border-collapse: collapse}TD { FONT-SIZE: 9pt}.bigfont{font-size:11pt; }.input { border:1px solid #C0C0C0; background-color: #F7F7F7}.sb{background-color: #F7F7F7;border:1px solid #C0C0C0;solid:#000000}.textarea{border:1px solid #C0C0C0; background-color: #F7F7F7}.text{border: 1 solid #C0C0C0}</style> </head><body topmargin="0" leftmargin="0"><center><TABLE WIDTH=425 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="450"><TR><TD height="440" valign="top"><img border="0" src="/teath/images/userRegister.jpg" width="425" height="75"><table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1" height="331"><tr><td width="23" bgcolor="#E9E9E9"> </td><td valign="top"><table border="0" width="99%" cellspacing="0" cellpadding="0" id="table2" height="350"><tr><td width="11"> </td><td valign="top"><form action="check_register.jsp" name="form" method="post" onSubmit="return check()"><table border="0" width="350"><tr><td width="92" align="center"><font color="#FF0000">*</font>用 户 名:</td><td width="248" align="left"><input type="text" name="username" size="12"> 用户名大于4小于20个字符</td></tr><tr><td width="92" align="center"><font color="#FF0000">*</font>密 码:</td><td width="248" align="left"><input type="password" name="password" size="12"> <font color="#FF0000"> </font> 密码大于6小于20个字符</td></tr><tr><td width="92" align="center"><font color="#FF0000">*</font>重复密码:</td><td width="248" align="left"><input type="password" name="password2" size="12"> <font color="#FF0000"> </font>必须与上面一致</td></tr><tr><td width="92" align="center"><font color="#FF0000">*</font>电子邮箱:</td><td width="248" align="left"><input type="text" name="email" size="12">E-MAIL必须符合规则</td></tr><td width="92" align="center"><font color="#FF0000">*</font>性 别:</td><td width="248" align="left">男<input type="radio" name="sex" value="male"> 女<input type="radio" name="sex" value="female"> <font color="#FF0000"> </font> 性别不能为空</td><tr> <td width="92" align="center"><font color="#FF0000">*</font>QQ号码:</td><td width="248" align="left"><input type="text" name="qq" size="12"> <font color="#FF0000"> </font> qq不能为空</td></tr><tr><td width="92" align="center"><font color="#FF0000">*</font>问 题:</td><td width="248" align="left"><input type="text" name="question" size="34"></td></tr><tr><td width="92" align="center"><font color="#FF0000">*</font>答 案:</td><td width="248" align="left"><input type="text" name="answer" size="34"></td></tr><tr> <td width="92" align="center" valign="top">个人介绍:</td> <td width="248" align="left"><textarea name="words" cols="34" rows="5" ></textarea></td></tr><tr> <td align="right"><a href="#" onClick="javascript:var dt=new Date();document.getElementById('code').src='image.jsp?dt='+dt;">看不清楚换一张</a></td> <td><img id="code" border=0 src="image.jsp"></td> </tr><tr> <td width="92" align="center">验证码:</td><td width="248" align="left"><input type="rang" name="rand" size="12"></td></tr><tr><td colspan="2" align="left" height="117" valign="top"><br><center><input type="submit" name="submit" value="注册" class="sb"> <input name="reset" type="reset" class="sb" id="reset" value="清空"></center></td></tr></table></form></td><td width="11"> </td></tr></table></td><td width="24" bgcolor="#E9E9E9"> </td></tr></table></TD></TR></TABLE></BODY></HTML><script language="javascript"> function check() {username=trim(document.form.username.value);password=trim(document.form.password.value);password2=trim(document.form.password2.value);email=trim(document.form.email.value);question=trim(document.form.question.value); answer=trim(document.form.answer.value); qq=trim(document.form.qq.value); rand=trim(document.form.rang.value);if(username.length<4||username.length>20){alert("用户名长度必须在4~20位之间!"); return false;}if(passwors.length<6||password.length>20){alert("密码长度必须在6~20位之间!"); return false;}if(password!=passwoed2){alert("密码不匹配!"); return false;}if(email=""||(email.indexOf('@')==-1)||(email.indexOf('.')==-1)){alert("Email格式有误,请重新输入有效邮箱地址!"); return false;}if(question.length<4) { alert("问题长度必须大于4!"); return false; } if(answer.length<2) { alert("答案长度必须大于2!"); return false; } if(qq.length==0) { alert("请输入qq!"); return false; }if(rand.length==0) { alert("请输入验证码!"); return false;}return true;}</script> 问题补充:richard_2010 写道
解决方案
String str_qq=request.getParmaeter("qq"); //这行拼写错误