| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 541 人关注过本帖
标题:[解决]请教!在用户注册时检查已有用户名
只看楼主 加入收藏
tanlin
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-4-2
收藏
 问题点数:0 回复次数:1 
[解决]请教!在用户注册时检查已有用户名

Register.asp
<html>
<head>
<SCRIPT language="JavaScript">
<!--
function Check()
{
window.open("regcheck.asp?username="+document.reg.username.value,"","width=200,height=100,left=270,top=270");
}
-->
</script>
<title>注册界面</title>
</head>


<body bgcolor="#E1E1E1">

<form action="AddUser.asp" method="post" name="reg">
<table height="170" width="950" background="../image/页头.jpg" align="center">
<tr><td></td></tr>
</table>
<table bgcolor="#CCCCCC" height="34" width="950" align="center">
<tr><td height="28"><h1 align="center">用 户 注 册 信 息</h1></td></tr>
</table>
<table bgcolor="#CCCCCC" height="20" width="950" align="center">
<tr><td width="435" height="14" align="right"><font color="#FF6666" size="-1">注意:有*标记的内容是必填项 </font></td>
<td width="503"></td>
</tr>
</table>
<table bgcolor="#CCCCCC" height="192" width="950" align="center">
<tr><td height="20"></td></tr>
<tr><td width="332" height="31" align="right">用户名:<font color="#FF6666">*</font></td>
<td width="606"> <input type="text" name="username" size="11" ><font size="-1" color="#FF6666">
<input type="button" onClick="Check()" value="检查用户名">
可以是中文,长度在11字节以内</font></td></tr>
<tr><td height="31" align="right">真&nbsp;&nbsp;名:<font color="#FF6666">*</font></td>
<td><input type="text" name="name" size="18"></td></tr>
<tr><td height="31" align="right">年&nbsp;&nbsp;龄:</td>
<td><input type="text" name="age" size="16"></td></tr>
<tr><td height="31" align="right">性&nbsp;&nbsp;别:</td>
<td><select name="sex" size="1">
<option value="男">男</option>
<option value="女">女</option>
</select></td></tr>
<tr><td height="31" align="right">电&nbsp;&nbsp;话:</td>
<td><input type="text" name="phone" size="20"></td></tr>
<tr><td height="31" align="right">电子邮箱:</td>
<td><input type="text" name="mail" size="30"></td></tr>
<tr><td height="31" align="right">密&nbsp;&nbsp;码:<font color="#FF6666" size="-1">*</font><br><br ></td>
<td><input type="password" name="password" size="11" /><font color="#FF6666" size="-1">注意:密码不能超过11位</font></td></tr>
<tr><td height="31" align="right">确认密码:<font color="#FF6666" size="-1">*</font></td>
<td><input type="password" name="Verifypassword" size="11"><font color="#FF6666" size="-1">注意:密码不能超过11位</font></td></tr>
</table>
<table bgcolor="#CCCCCC" height="89" width="950" align="center">
<tr><td>
<hr align="center" size="1" width="300">
<p align="center">&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="确定" size="50">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value="重置" size="50">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="退出" onClick="window.location='../index.asp'"></p>
</td></tr>
</table>
<table height="150" width="950" background="../image/页尾.jpg" align="center">
<tr><td></td></tr>
</table>
</form>
</body>
</html>

regcheck.asp
<%
dim conn,sql,rs,yhm,result
yhm=request("username")
Set conn = Server.CreateObject("ADODB.Connection")
sql="Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\毕业设计\data\data.mdb"
conn.Open sql
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from login where username='"&username&"'",conn,1,3
if not(rs.bof and rs.eof) then
response.Write ("<p align=center><font color='#FF0000'>请另外选择用户名!</font></P>")
response.Write ("<p align=center><INPUT TYPE='BUTTON' value='关闭' onClick='window.close()'></P> ")
else
response.Write ("<p align=center><font color='#FF0000'>恭喜!你还可以注册该帐号!</font></P>")
response.Write ("<p align=center><INPUT TYPE='BUTTON' value='关闭' onClick='window.close()'></P> ")
end if
%>
为什么我输入用户名无论是什么都是请另外选择用户名!.请教?

[此贴子已经被作者于2006-4-3 14:41:56编辑过]

搜索更多相关主题的帖子: 用户名 username head body 
2006-04-02 20:46
tanlin
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-4-2
收藏
得分:0 
阳光白雪 14:37:22
rs.Open "select * from login where username='"& yhm &"'",conn,1,3

阳光白雪 14:37:52
你写的是
rs.Open "select * from login where username='"&username&"'",conn,1,3  

谢谢阳光白雪!
这个问题.我和我寝室看了半天没有看到问题

[此贴子已经被作者于2006-4-3 14:44:10编辑过]

2006-04-03 14:43
快速回复:[解决]请教!在用户注册时检查已有用户名
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015088 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved