jsp 使用者留言板程式

來源:互聯網
上載者:User

 

 代碼如下 複製代碼
<table class="k123"
style="MARGIN-TOP: 15px; BORDER-COLLAPSE: collapse"
bordercolor="#cccccc" cellspacing="0" cellpadding="4"
width="360" align="center" bgcolor="#ffffff" border="1">
<tbody>
<tr>
<td class="f12black" align="right"
height="18">寄件者:</td>
<td class="f12black" align="left"><label>
  <input class="input" style="FONT-SIZE: 14px; WIDTH: 100px; HEIGHT: 16px" maxlength="36" size="22" name="name" />
</label></td>
</tr>
<tr>
<td class="f12black" align="right" width="84"
bgcolor="#f9f9f9">留言標題:</td>
<td class="f12black" align="left" width="254" bgcolor="#f9f9f9">
<input class="input" style="FONT-SIZE: 14px; WIDTH: 160px; HEIGHT: 19px" maxlength="36" size="18" name="title" /></td>
</tr>
<tr>
<td class="f12black" align="right">留言內容:</td>
<td class="f12black" align="left">
<textarea class="input" style="FONT-SIZE: 14px" name="content" rows="4" cols="30"></textarea></td>
</tr>
<tr>
<td class="f12black" align="middle" colspan="2">
<input type="button" value="提交你的留言" name="cmdOk" />
  &nbsp;</td>
</tr>
</tbody>
</table>


                         
留言儲存
                       

 代碼如下 複製代碼

<%
String url ="jdbc:mysql://localhost/zkh131_db?user=zkh131&password=n3a9q2e3&useUnicode=true&characterEncoding=gb2312";
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn= DriverManager.getConnection(url);


java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date currentTime = new java.util.Date();
String nowTime = formatter.format(currentTime);
if(request.getParameter("title")=="fdsafdsaf_fd_XXX"){
 String namec=new String(request.getParameter("name").getBytes("iso-8859-1"));
 String titlec=new String(request.getParameter("title").getBytes("iso-8859-1"));
 String contentc=new String(request.getParameter("content").getBytes("iso-8859-1"));
 Statement stmtADDd=conn.createStatement();
 String Sqladd="insert into hl_book (Name,Title,Content,thisTime) values ('"+namec+"','"+titlec+"','"+contentc+"','"+nowTime+"')";
 int addd=stmtADDd.executeUpdate(Sqladd);
 out.print("<script type="text/javascript"> alert("您的留言成功,感謝您對我們的關注!"); window.location.href='service.jsp'; </script>"); 
 return ;
}
%>
 


 顯示留言
                         

 代碼如下 複製代碼
<%
 ResultSet Rsn=stmt1.executeQuery("Select * from hl_book where Rebook!='' order by id desc limit 1");
 if(Rsn.next()) {
 %>
      <table style="MARGIN-TOP: 5px; MARGIN-RIGHT: 12px" width="94%" align="center" bgcolor="#cccccc" border="0">
        <tbody>
          <tr>
            <td align="middle" width="81" bgcolor="#eeeeee" height="25">主 題</td>
            <td align="left" width="466" bgcolor="#eeeeee" height="25">&nbsp;&nbsp;<%=Rsn.getString("Title")%>&nbsp;&nbsp;[<%=Rsn.getString("thisTime")%>]</td>
          </tr>
          <tr>
            <td align="middle" bgcolor="#ffffff" height="25">內 容</td>
            <td align="left" bgcolor="#ffffff" height="25">&nbsp;&nbsp;<%=Rsn.getString("Content")%></td>
          </tr>
          <tr>
            <td align="middle" bgcolor="#ffffff" height="25"><font color="#ff0000">回複內容</font></td>
            <td align="left" bgcolor="#ffffff" height="25"><font color="#ff0000">&nbsp;&nbsp;<%=Rsn.getString("Rebook")%> </font></td>
          </tr>
        </tbody>
    </table>
 <%
 }
 Rsn.close();
 %>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.