这个是acc.asp中的内容: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <% option explicit dim conn,db,sql,username,userphone db="mdb/aaaa.mdb" Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) sql="select *from aaaaa" Set rs = Server.CreateObject("ADODB.RecordSet") username=request.form("username") userphone=request.form("userphone") if username<>"" and userphone<>"" then do while not rs.eof if username=rs.("name") response.write "该用户已经存在" else rs.movenext loop end if else sql="insert into aaaaa (name,phone) values ('"&username&"','"&userphone&"')" conn.Execute(sql) response.write "用户:"&username&"添加成功!" end if conn.close set conn=nothing %> 这个是 测试插入数据.htm中的内容: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>测试插入数据</title> <style type="text/css"> <!-- .style1 { font-family: "宋体"; font-size: 10pt; } --> </style> </head>
<body> <table width="412" cellspacing="0" cellpadding="0"> <tr> <td width="410"><form name="form1" method="post" action="acc.asp"> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="44%"><span class="style1">用户名:</span> <input name="textname" type="text" id="textname" size="15"></td> <td width="56%"><span class="style1">电话:</span> <input name="textphone" type="text" id="textphone" size="15"> <input type="submit" name="Submit" value="提交"></td> </tr> </table> </form></td> </tr> </table> </body> </html> 我想在点击“提交“后进行验证,如果用户名有重复的,就提示错误,如果没有,就插入数据,这么做可以么??我怎么点完"提交"之后没有反应呢? 能帮我看看么....谢谢!!!