⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 product_add3.asp

📁 本实例为一个完整的网上购物商城的完整例子程序,里面有所以的源代码.希望对大家学习有用.
💻 ASP
字号:
<!--#include file="conn.asp"-->
<%
if session("admin_name")="" then
        response.redirect "error.asp?error=001"
end if
%>
<script language="JavaScript">
function CheckForm()
{ 
        if(document.addproduct.product_name.value.length == 0)
        {
                alert("请输入商品名.");
                document.addproduct.product_name.focus();
                return false;
        }
        if(document.addproduct.price.value.length == 0)
        {
                alert("请输入商品的价格.");
                document.addproduct.price.focus();
                return false;
        }
        
        if(document.addproduct.sprice.value.length == 0)
        {
                alert("请输入商品的市场价格.");
                document.addproduct.sprice.focus();
                return false;
        }
        return true;
}
</script>
<%
if request("action")="add" then
        '开始添加商品
bianhao=request("bianhao")
product_name=trim(request("product_name"))
price=request("price")
sprice=request("sprice")
vprice=request("vprice")
cprice=request("cprice")
nprice=request("nprice")
sort_name=request("sort_name")
csort_name=request("csort_name")
aday=request("aday")
day=request("day")
info=replace(request("info"), ">", "&gt;")
info=replace(info, "<", "&lt;")
info=replace(info, "'","’")
if info="" then info="此商品暂无介绍"
        stj=request("stj")
ytj=request("ytj")
etj=request("etj")
cx=request("cx")
pic=request("pic")
cpic=request("cpic")
cinfo=request("cinfo")
bzhuang=request("bzhuang")
company=request("company")
brand=request("brand")
dim day
day=now()
'开始检测此产品名是否重复登陆
set rs=server.createobject("ADODB.Recordset")
sql="select * from 56770_product where product_name='"&product_name&"' order by id desc"
rs.open sql, conn, 1, 1
if not(rs.eof or rs.bof)then
        response.write"<SCRIPT language=JavaScript>alert('对不起,您所添加的商品其商品名已经存在, 请核实!');"
response.write"javascript:history.go(-1)</SCRIPT>"
rs.close
set rs=nothing
response.end
end if
'结束检验,添加商品
'conn.execute "insert into 56770_product(product_name, price, sprice, vprice, cprice, info, pic, cpic, company, brand, sort_name, csort_name, cinfo, bzhuang, day)values('"&product_name&"', '"&price&"', '"&sprice&"', '"&vprice&"', '"&cprice&"', '"&info&"', '"&pic&"', '"&cpic&"', '"&company&"', '"&brand&"', '"&sort_name&"', '"&csort_name&"', '"&cinfo&"', '"&bzhuang&"', '"&day&")"
conn.execute "insert into 56770_product (product_name,price, sprice, vprice, cprice, info, pic, cpic, company, brand, sort_name, csort_name, cinfo, bzhuang)values('"&product_name&"', '"&price&"', '"&sprice&"', '"&vprice&"', '"&cprice&"', '"&info&"', '"&pic&"', '"&cpic&"', '"&company&"', '"&brand&"', '"&sort_name&"', '"&csort_name&"', '"&cinfo&"', '"&bzhuang&"')"
'取得添加商品ID,添加商品编号及推荐促销项目
set rs=server.createobject("ADODB.Recordset")
sql="select * from 56770_product order by id desc"
rs.open sql, conn, 1, 1
id=rs("id")
rs.close
set rs=nothing
bianhao=bianhao & "-" & xnumber & "-" & id
conn.execute "update 56770_product set bianhao='"&bianhao&"' where id=" & id
'判断为何推荐
if etj="on" then conn.execute "update 56770_product set etj=true where id=" & id
        if cx="on" then conn.execute "update 56770_product set cx=true where id=" & id
        if stj="on" then conn.execute "update 56770_product set stj=true where id=" & id
        if ytj="on" then conn.execute "update 56770_product set ytj=true where id=" & id
        conn.execute "update 56770_product set day=now() where id=" & id
response.write"<SCRIPT language=JavaScript>alert('商品添加成功 返回继续添加!');"
response.write"javascript:history.go(-2)</SCRIPT>"
response.end
end if
%>
<%
sort_name=request("sort_name")
csort_name=request("csort_name")
number=request("number")
cnumber=request("cnumber")
bianhao=number & "-" & cnumber
if sort_name="" or number="" or csort_name="" or cnumber="" then
        response.write"<SCRIPT language=JavaScript>alert('对不起,请选择您要操作的商品分类项!');"
response.write"javascript:history.go(-1)</SCRIPT>"
response.end
end if
%>
<html>
<head>
<title>后台管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="css.css" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#FFFFFF" vspace="0" hspace="0">
<tr>
<td height="27" background="images/admin_bg_1.gif">.:: 您可以在这里进行商品相关操作</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#FFFFFF" vspace="0" hspace="0">
<tr>
<td height="27">.:: 商品图片地址格式为####.gif.请勿使用目录.</td>
</tr>
</table>
<table border="0" cellspacing="1" cellpadding="3" width="100%" align="center" background="images/admin_bg_1.gif">
<form action="product_add3.asp" method="post" name="addproduct" onSubmit="return CheckForm();">
<tr bgcolor="#6699CC">
<td colspan="6" height="25"> 您现在要添加的商品一级分类为:<a href="product_add1.asp"><%=sort_name%></a>,
二级分类为:<ahref="product_add2.asp?sort_name=<%=sort_name%>&number=<%=number%>"><%=csort_name%></a>
</td>
</tr>
<tr>
<td bgcolor="#BBD1E8" width="12%" > 产品全称:<br>
</td>
<td bgcolor="#BBD1E8" colspan="2">&nbsp;
<input type="text" name="product_name" size="26" >
   </td>
<td bgcolor="#BBD1E8"colspan="3">
<input type="checkbox" name="etj" checked>
平价
<input type="checkbox" name="cx">
促销
<input type="checkbox" name="stj">
首页推荐
<input type="checkbox" name="ytj">
一级类推荐
</td>
</tr>

<tr bgcolor="#6699CC">
<td  height="25" colspan="6">
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>市场价格:</td>
<td><input type="text" name="sprice" size="8" maxlength="45" ></td>
<td>会员价格:</td>
<td>&nbsp; <input type="text" name="price" size="8" maxlength="45"></td>
<td>VIP价格</td>
<td>&nbsp; <input type="text" name="vprice" size="8" maxlength="45" value="1"></td>
<td>促销特价:</td>
<td>
<input type="text" name="cprice" size="8" maxlength="45"  value="1">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" valign="top" bgcolor="#BBD1E8" width="12%">商品介绍:</td>
<td colspan="6" bgcolor="#BBD1E8"><br>
&nbsp;
<textarea name="info" rows="5" cols="50"></textarea>
<br>
<br>
</td>
</tr>
<tr>
<td  bgcolor="#BBD1E8" width="12%">规格: </td>
<td bgcolor="#BBD1E8"colspan="3">&nbsp;
<input type="text" name="cinfo" size="20">
</td>
<td bgcolor="#BBD1E8" width="8%">包装:</td>
<td bgcolor="#BBD1E8" width="42%">
<input type="text" name="bzhuang" size="20">
</td>
</tr>
<tr>
<td  bgcolor="#BBD1E8" width="12%">出品公司: </td>
<td bgcolor="#BBD1E8"colspan="3">&nbsp;
<input type="text" name="company" size="20" value="不详">
</td>
<td bgcolor="#BBD1E8" width="8%">品牌:</td>
<td bgcolor="#BBD1E8" width="42%">
<input type="text" name="brand" size="20" value="不详">
</td>
</tr>
<tr>
<td  bgcolor="#BBD1E8" width="15%"> 商品小图片:</td>
<td bgcolor="#BBD1E8"colspan="3">&nbsp;
<input type="text" name="pic" size="20" value="noimages.gif">
</td>
<td bgcolor="#BBD1E8" width="15%">商品大图片:</td>
<td bgcolor="#BBD1E8" width="42%">
<input type="text" name="cpic" size="20"  value="noimages.gif">
</td>
</tr>
<tr>
<td  bgcolor="#BBD1E8" width="12%"> 图片上传: </td>
<td bgcolor="#BBD1E8"colspan="5"><iframe name="Upload" frameborder="0" width="100%" height="25" scrolling="no" src="upload_1.asp"></iframe></td>
</tr>
<tr bgcolor="#D6DFF7">
<td height="35" colspan="6">
<div align="center">
<input type="submit" name="Submit" value="添加" class="Submit">
&nbsp; &nbsp;
<input type="reset" name="Submit" value="重填" class="Submit">
<input type="hidden" name="action" value="add">
<input type="hidden" name="sort_name" value="<%=sort_name%>">
<input type="hidden" name="csort_name" value="<%=csort_name%>">
<input type="hidden" name="bianhao" value="<%=bianhao%>">
</div>
</td>
</tr>
</form>
</table>
<p>&nbsp; </p>
</body>
</html>

⌨️ 快捷键说明

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