ASP中检查到注册信息有误如何阻止数据写入数据库?

来源:百度知道 编辑:UC知道 时间:2024/05/22 07:53:45
<%@ language="vbscript" codepage="936"%>
<!-- #include file="conn.asp" -->
<html>
<head>
<title>论坛注册</title>
<script for="button1" event="onclick" language="vbscript">
m=form1.name1.value
n=form1.pwd.value
w=form1.pwd1.value
if m="" or n="" or w="" then
msgbox "带星号的不能为空"
end if
if n<>w then
msgbox "确认密码不正确"
end if

</script>
</head>

<%

dim thename,thepwd
thename=request.form("name1")
thepwd=request.form("pwd")

Set Rs=Server.CreateObject("adodb.recordset")
Rs.open "select * from zhuce where id is null",conn,1,3
Rs.addnew
Rs("name")=thename
Rs("password&qu

<script for="button1" event="onclick" language="vbscript">
m=form1.name1.value
n=form1.pwd.value
w=form1.pwd1.value
if m="" or n="" or w="" then
msgbox "带星号的不能为空"
return false
end if
if n<>w then
msgbox "确认密码不正确"
return false
end if

</script>
-----------------------
加上return false就可以了

建议在服务器端进行数据安全性检查,即进行防SQL注入检查,具体可以参考我空间上的文章:
http://hi.baidu.com/zjcn5205/blog/item/bcb11cdf0b9613136227987d.html