anews_ok.asp

来自「这是一个网上购物物网站,数据库的连接在CONN.ASP中,既有前台网站,也有后台」· ASP 代码 · 共 36 行

ASP
36
字号
<!--#include file="conn.asp"-->
<%
action=request("action")
if action="add" then    '添加数据

if request("name")="" then 
	Response.Write("<script>alert('标题不能为空,请填写!');history.back(-1);</script>")
response.end
end if
if request("content")="" then 
	Response.Write("<script>alert('内容不能为空,请填写!');history.back(-1);</script>")
response.end
end if
    set rs=server.createobject("adodb.recordset")
	rs.open "select * from news",conn,3,2
	rs.addnew	
    rs("name")=request("name")
    rs("type")=request("type")
    rs("content")=request("content")
	rs.update
	Response.Write("<script>alert('添加成功!');window.location='anews_add.asp';</script>")

elseif action="mdf" then   '修改数据
	set rs=server.createobject("adodb.recordset")
	rs.open"select * from news where id=" &request("id"),conn,1,3
	rs("name")=request("name")
    rs("type")=request("type")
    rs("content")=request("content")
	rs.update
	Response.Write("<script>alert('修改成功!');window.location='anews_list.asp';</script>")
elseif action="del" then   '删除数据
	sql="delete from news where id=" &request("id")
    set rs=conn.execute(sql)
	Response.Write("<script>alert('删除成功!');window.location='anews_list.asp';</script>")
end if
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?