当前位置: 代码迷 >> ASP >> 注册的简单有关问题,怎么检索数据库中的用户名和邮箱是否存在,都不允许重复;最好能对resinger.asp中的user,pass,email,进行上检测
  详细解决方案

注册的简单有关问题,怎么检索数据库中的用户名和邮箱是否存在,都不允许重复;最好能对resinger.asp中的user,pass,email,进行上检测

热度:682   发布时间:2012-10-21 09:00:07.0
注册的简单问题,如何检索数据库中的用户名和邮箱是否存在,都不允许重复;最好能对resinger.asp中的user,pass,email,进行下检测?
resinger.asp

VB code
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<!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>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <p>用户名
    <input name="user" type="text" id="user" />
  </p>
  <p>邮箱
    <input name="email" type="text" id="email" />
</p>
  <p>
    密码
      <input name="pass" type="text" id="pass" />
  </p>
  <p>
    确认密码
      <input name="pass2" type="text" id="pass2" />
      </p>
  <p>
    <input type="submit" name="Submit" value="提交" />
    <input type="reset" name="Submit2" value="重置" />
  </p>
</form>
</body>
</html>



save.asp
VB code
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!--#include file = "md5.asp"-->
<!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>
</head>

<body>
<%
name=Trim(Request.Form("name"))
pass=md5(Trim(Request.Form("pass")))
email=Trim(Request.Form("email"))
Set rs = server.CreateObject("adodb.recordset")
sql="select name="&name&"  and email="&email&""




rs.Open sql, conn, 1, 1  


%>
</body>
</html>



------解决方案--------------------
sql="select * From TableName name='" & name & "' and email='" & email & "'"

Set rs = conn.Execute(sql)
Dim HasName
HasName = rs.EOF 
rs.Close
If HasName Then
 sql = "Insert into ......."
Else
 Response.Write "改用户已经存在"
End If
  相关解决方案