jsp資料更新代碼
<script language="javascript">
function form1_onsubmit()
{
if (document.form1.SiteName.value=="")
{
window.alert("請輸入網站名稱");
return false;
}
}
// 修改編輯欄高度
function Textarea_Size(num,objname)
{
var obj=document.getElementById(objname)
if (parseInt(obj.rows)+num>=3) {
obj.rows = parseInt(obj.rows) + num;
}
if (num>0)
{
obj.width="90%";
}
}
</script>
</head>
<%
String Aforder=(String)session.getAttribute("Aforder");
%>
<body>
<br />
<a href="SiteConfig_Info.jsp">網站資訊</a><% if(Aforder.equals("1")){ %> | <a href="SiteConfig_Update.jsp">資訊修改</a><% } %>
<hr color="#0099FF" size="1" />
<%
if (request.getParameter("SiteName") != null)
{
String SiteName=new String(request.getParameter("SiteName").getBytes("iso-8859-1"));
String SiteUrl=new String(request.getParameter("SiteUrl").getBytes("iso-8859-1"));
String SiteTitle=new String(request.getParameter("SiteTitle").getBytes("iso-8859-1"));
String ftel=new String(request.getParameter("ftel").getBytes("iso-8859-1"));
String ffax=new String(request.getParameter("ffax").getBytes("iso-8859-1"));
String address=new String(request.getParameter("address").getBytes("iso-8859-1"));
String fcode=new String(request.getParameter("fcode").getBytes("iso-8859-1"));
String email=new String(request.getParameter("email").getBytes("iso-8859-1"));
String MetaKeywords=new String(request.getParameter("MetaKeywords").getBytes("iso-8859-1"));
String MetaDescription=new String(request.getParameter("MetaDescription").getBytes("iso-8859-1"));
Statement stmt_ConfigUpdate=conn.createStatement();
String Sql_U="update hl_SiteConfig set fSiteName='"+SiteName+"',fSiteUrl='"+SiteUrl+"',fSiteTitle='"+SiteTitle+"',ftel='"+ftel+"',ffax='"+ffax+"',address='"+address+"',email='"+email+"',fcode='"+fcode+"',fMetaKeywords='"+MetaKeywords+"',fMetaDescription='"+MetaDescription+"' where ID=1";
int gai=stmt_ConfigUpdate.executeUpdate(Sql_U);
stmt_ConfigUpdate.close();
if (gai>0)
{
out.print("<p align='center'>["+ SiteName +"]網站配置修改成功</p>");
}
}
Statement stmt_SiteConfig=conn.createStatement();
String Sql="Select * from hl_SiteConfig";
ResultSet RsSiteConfig=stmt_SiteConfig.executeQuery(Sql);
RsSiteConfig.next();
%>
<form id="form1" name="form1" method="post" action="" onsubmit="return form1_onsubmit()">
<table width="700" border="0" align="center">
<tr>
<td width="120" align="right">網站名稱:</td>
<td><input name="SiteName" type="text" value="<%=RsSiteConfig.getString("fSiteName")%>" size="40"/></td>
</tr>
<tr>
<td align="right">網站網址:</td>
<td><input name="SiteUrl" type="text" value="<%=RsSiteConfig.getString("fSiteUrl")%>" size="30"/>
* 輸入 http:// </td>
</tr>
<tr>
<td align="right">公司名稱:</td>
<td><input name="SiteTitle" type="text" value="<%=RsSiteConfig.getString("fSiteTitle")%>" size="40" /></td>
</tr>
<tr>
<td align="right">公司電話:</td>
<td><input name="ftel" type="text" value="<%=RsSiteConfig.getString("ftel")%>" size="20" /></td>
</tr>
<tr>
<td align="right">公司傳真:</td>
<td><input name="ffax" type="text" value="<%=RsSiteConfig.getString("ffax")%>" size="20" /></td>
</tr>
<tr>
<td align="right">公司郵箱:</td>
<td><input name="email" type="text" value="<%=RsSiteConfig.getString("email")%>" size="30" /></td>
</tr>
<tr>
<td align="right">公司地址:</td>
<td><input name="address" type="text" value="<%=RsSiteConfig.getString("address")%>" size="30" /></td>
</tr>
<tr>
<td align="right">郵 編:</td>
<td><input name="fcode" type="text" value="<%=RsSiteConfig.getString("fcode")%>" size="15" /></td>
</tr>
<tr>
<td align="right">網站關鍵字:</td>
<td><textarea name="MetaKeywords" cols="60" rows="6" id="MetaKeywords"><%=RsSiteConfig.getString("fMetaKeywords")%></textarea>
<a href="javascript:Textarea_Size(-5,'MetaKeywords')" title="減小編輯區">
<font face="Wingdings" size="3" color="#0000FF">ñ</font></a>
<a href="javascript:Textarea_Size(5,'MetaKeywords')" title="增高編輯區">
<font face="Wingdings" size="3" color="#0000FF">ò</font></a>
</td>
</tr>
<tr>
<td align="right">網站描述:</td>
<td>
<textarea name="MetaDescription" cols="60" rows="6" id="MetaDescription"><%=RsSiteConfig.getString("fMetaDescription")%></textarea>
<a href="javascript:Textarea_Size(-5,'MetaDescription')" title="減小編輯區">
<font face="Wingdings" size="3" color="#0000FF">ñ</font></a>
<a href="javascript:Textarea_Size(5,'MetaDescription')" title="增高編輯區">
<font face="Wingdings" size="3" color="#0000FF">ò</font></a>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="修 改" />
<input type="reset" name="Reset" value="重 置" /></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
<%
RsSiteConfig.close();
stmt_SiteConfig.close();
conn.close();
%>