比如说
<form name="form1">
<input name="admin" type="text" size="20" maxlength="30" class="bd01">
<input type="button" name="button1" value="检查用户是否存在" onClick="UserExist();" class="butt1">
.....
</form>
<script language="javascript">
function UserExist()
{
var name = document.form1.admin.value;
window.open("UserExist.asp?admin="+name);
}
</script>
UserExist.asp
<!--#include file="../inc/conn.asp"-->
<%
admin =Request("admin")
if admin="" then
Response.Redirect("../error/error.asp")
end if
set rs=Server.CreateObject("adodb.recordset")
sql ="select * from admin where admin='" & admin & "' order by id desc"
rs.open sql,conn,1,3
if not rs.eof then
Response.write "此用户已存在!"
else
Response.write admin&"这个用户目前不存在,你可以使用这个用户进行添加!"
end if
%>
<%连接数据库%>
set rst=server.createobject("adodb.recordset")
sql="select count(*) as recnum from 表名 where name='"&request.form("name")&"'"
rst.open sql,conn,1,1
if rst("recnum")>0 then
response.Write "已经存在同名用户!"
else
sql="insert into check (name,password) values('"&request.form("name")&"','"&request.form("password")&"')"
conn.execute sql
end if
%>