📄 add.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<html>
<head>
<title>增加留言</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/style" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#CCCCCC">
<%String action=request.getParameter("action");
if (action==null)
{%>
<form name="form1" method="post" action="/guestbook/add.jsp?action=add">
<table width="41%" height="267" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr bgcolor="#FFFFFF">
<td height="27" colspan="2" align="center" background="images/table.gif">书写留言</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="19%" height="27" align="center">姓名:</td>
<td width="81%" height="27"><input name="username" type="text" id="username"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="27" align="center">性别:</td>
<td height="27"><select name="sex" id="sex">
<option value="男" selected>男</option>
<option value="女">女</option>
</select></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="27" align="center">邮件:</td>
<td height="27"><input name="email" type="text" id="email"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25" align="center">网址:</td>
<td height="25"><input name="url" type="text" id="url"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="31" align="center">QQ:</td>
<td height="31"><input name="qq" type="text" id="qq"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="31" align="center">头象:</td>
<td height="31"><input name="tx" type="radio" value="images/face01.gif" checked>
<img src="images/face01.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face02.gif">
<img src="images/face02.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face03.gif">
<img src="images/face03.gif" width="32" height="32"> <br>
<input type="radio" name="tx" value="images/face04.gif">
<img src="images/face04.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face05.gif">
<img src="images/face05.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face06.gif">
<img src="images/face06.gif" width="32" height="32"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="31" align="center">留言内容:</td>
<td height="31"><textarea name="content" cols="40" rows="10" id="content"></textarea></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="31" colspan="2" align="center"><input type="submit" name="Submit" value="增加">
<input type="reset" name="Submit2" value="重写">
<input type="button" name="Submit22" value="返回" onClick="window.location.href='index.jsp'"></td>
</tr>
</table>
</form>
<%}else{%><jsp:useBean id="guestbook" class="guestbook.GuestBookJdbc" scope="page"/>
<%
String username=request.getParameter("username");
String tx=request.getParameter("tx");
String email=request.getParameter("email");
String url=request.getParameter("url");
String sex=request.getParameter("sex");
String qq=request.getParameter("qq");
String ip=request.getRemoteAddr();
String content=request.getParameter("content");
Connection conn=guestbook.GetConn();
Statement sqlrs= conn.createStatement() ;
String sql="insert into Guestbook(username,tx,email,url,qq,content,ip,sex) values('"+username+"','"+tx+"','"+email+"','"+url+"','"+qq+"','"+content+"','"+ip+"','"+sex+"')";
try{
sqlrs.executeUpdate(sql);
response.sendRedirect("index.jsp");
}catch(Exception e)
{
out.print("出错了!");
}
}%>
<table width="75%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="22" align="center">CopyRight 2003-2005 © 重庆杰诺软件版权所有 </td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -