展开全部
代码asp 部分因为没有限制,所以一打开这个页面就执行插入。
要改两个地方:
1) <form method="post" action="add.asp"> 改为 <form method="post" action="add.asp?do=yes">
2) <% dim bumber1 这里加上判断,当接收到 do=yes 时才执行这段ASP代码
<%
if request("do")="yes" then '当接收到 do=yes 时才执行这段ASP代码
dim bumber1
dim id1
dim name1
dim shuxing1
number1=request("number1")
id1=request("id1")
name1=request("name1")
shuxing1=request("shuxing1")
sql="INSERT INTO chanpin (number,id,name,shuxing) VALUES ('"&number1&"','"&id1&"','"&name1&"','"&shuxing1&"')"
conn.execute sql
on error resume next
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
end if
%>
要改两个地方:
1) <form method="post" action="add.asp"> 改为 <form method="post" action="add.asp?do=yes">
2) <% dim bumber1 这里加上判断,当接收到 do=yes 时才执行这段ASP代码
<%
if request("do")="yes" then '当接收到 do=yes 时才执行这段ASP代码
dim bumber1
dim id1
dim name1
dim shuxing1
number1=request("number1")
id1=request("id1")
name1=request("name1")
shuxing1=request("shuxing1")
sql="INSERT INTO chanpin (number,id,name,shuxing) VALUES ('"&number1&"','"&id1&"','"&name1&"','"&shuxing1&"')"
conn.execute sql
on error resume next
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
end if
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询