📄 add_flo1.jsp
字号:
<html>
<head>
<title> 淳.清凉网上鲜花坊</title>
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<meta name="keywords" content="淳.清凉花坊">
<meta name="description" content="淳.清凉花坊">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="/css/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: 12px}
.style2 {font-size: 12px}
.style3 {
color: #006600;
font-size: 12px;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF" >
<%! public String getString(String s)
{if(s==null) s="";
try {byte a[]=s.getBytes("ISO-8859-1");
s=new String(a);
}
catch(Exception e)
{}
return s;
}
%>
<% //获取session值,以及防止非法访问本页面
String name=request.getParameter("name");
name=getString(name);
String price1=request.getParameter("price");
price1=getString(price1);
float price = Float.parseFloat(price1);
String storage1=request.getParameter("storage");
int storage=Integer.parseInt(storage1);
String kind1=request.getParameter("kind");
kind1=getString(kind1);
String classify=kind1.substring(2);
String kind=kind1.substring(0,2);
String situ=request.getParameter("situation");
situ=getString(situ);
String meaning=request.getParameter("meaning");
meaning=getString(meaning);
String discript=request.getParameter("discript");
discript=getString(discript);
String image=request.getParameter("image");
image=getString(image);
String Id=kind+situ;
String last="01";
String ID=null;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); }
catch(ClassNotFoundException event) { }
try {
con=DriverManager.getConnection("jdbc:odbc:sun","sa","");
sql=con.createStatement();
String con1="select max(bouquetid) from bouquet where bouquetid like '"+Id+"%"+"'";
rs =sql.executeQuery(con1);
if(rs.next())
{ String bid=rs.getString(1);
int bId =Integer.parseInt(bid)+1;
ID="0"+Integer.toString(bId);
}
else {ID=Id+last;}
String str="'"+ID+"'"+","+"'"+name+"'"+","+"'"+classify+"'"+","+price+","+storage+","+"'"+meaning+"'"+","+"'"+discript+"'"+","+"'"+image+"'";
String con2= "INSERT INTO bouquet VALUES"+"("+str+")";
sql.executeUpdate(con2);
rs=sql.executeQuery("select * from bouquet where bouquetid="+"'"+ID+"'");
if(rs.next())
{ %>
<script LANGUAGE="javascript">
alert("成功添加新信息!");
window.location.href = "admin_flo.jsp";
</script>
<%}
else {%>
<script LANGUAGE="javascript">
alert("输入的信息有误!");
history.go(-1);
</script>
<%
}
con.close();
}
catch(SQLException e1) {
System.out.println(e1.getMessage());
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -