📄 list_add.jsp
字号:
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GB18030" import="java.sql.*,java.util.*,java.io.*"%>
<%@ include file="config.ini"%>
<%@ include file="conn.jsp"%>
<%@ include file="readlogin.jsp"%>
<%
//获取用户请求中提交的参数
String action=request.getParameter("action");
if(action==null) {action="";}
//如果提交的参数为save时,执行数据库插入操作
if(action.equals("save"))
{
//获取用户通过表单提交的联系人信息
String name=codeToString(request.getParameter("name"));
String sort=codeToString(request.getParameter("sort"));
String mobile=codeToString(request.getParameter("mobile"));
String home=codeToString(request.getParameter("home"));
String office=codeToString(request.getParameter("office"));
String email=codeToString(request.getParameter("email"));
String qq=codeToString(request.getParameter("qq"));
String msn=codeToString(request.getParameter("msn"));
String post=codeToString(request.getParameter("post"));
String address=codeToString(request.getParameter("address"));
String other=codeToString(request.getParameter("other"));
try
{
sqlstr="insert into list([user],[sort],[name],[mobile],[home],[office],[email],[qq],[msn],[post],[address],[other]) values('"+iCan+"','"+sort+"','"+name+"','"+mobile+"','"+home+"','"+office+"','"+email+"','"+qq+"','"+msn+"','"+post+"','"+address+"','"+other+"')";
//执行数据库中的插入记录操作
iCanDb.doAdd(sqlstr);
out.print("<script>");
out.print("alert('添加成功!');");
out.print("location.href='list.jsp';");
out.print("</script>");
}
catch(Exception e)
{
out.print("<script>");
out.print("alert('数据库错误!');");
out.print("location.href='list.jsp';");
out.print("</script>");
}
}
%>
<html>
<head>
<%@ include file="head.jsp"%>
</head>
<script language="javascript">
function on_submit()
{//验证数据的合法性
if (form1.name.value == "")
{
alert("姓名不能为空");
form1.name.focus();
return false;
}
}
</script>
<body>
<center>
<table border="0" width="768" id="table1" cellspacing="0" cellpadding="0">
<tr>
<%@ include file="top.jsp"%>
</tr>
<tr>
<td width="90" valign="top">
<%@ include file="menu.jsp"%> </td>
<td width="588" valign="top">
<table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="1" width="100%" id="table4" bordercolorlight="#0A9EE4" cellspacing="0" cellpadding="5" bordercolordark="#0A9EE4" height=300>
<tr>
<td valign="top">
<table border="0" width="100%" id="table5" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" width="100%" id="table6" cellspacing="0" cellpadding="0">
<tr>
<td valign="bottom" width="50%">
</td>
<td width="50%">
<img src="images/n-list.jpg" align="right" width="230" height="70"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><hr noshade color="#0A9EE4" size="1"></td>
</tr>
<tr>
<td><form method="POST" action="list_add.jsp?action=save" target=_top name="form1" onsubmit="return on_submit()">
<table border="0" width="574" id="table7" cellspacing="0" cellpadding="5">
<tr>
<td width="574" height="40">
<p align="left">
<span style="font-size: 9pt"> 姓名:<input type="text" name="name" size="15" style="border: 1px solid #0A9EE4">
分类:<select size="1" name="sort" style="border: 1px solid #0A9EE4">
<option selected value="家人、亲戚">家人、亲戚
</option>
<option value="同事、同学">同事、同学</option>
<option value="朋友">朋友</option>
<option value="网友、笔友">网友、笔友</option>
<option value="业务人士">业务人士</option>
<option value="其他">其他</option>
</select></span></td>
</tr>
<tr>
<td width="574" height="40">
<p align="left">
<span style="font-size: 9pt">
移动电话:<input type="text" name="mobile" size="12" style="border: 1px solid #0A9EE4">
住宅电话:<input type="text" name="home" size="12" style="border: 1px solid #0A9EE4">
办公电话:<input type="text" name="office" size="12" style="border: 1px solid #0A9EE4"></span></td>
</tr>
<tr>
<td width="574" height="40">
<p align="left">
<span style="font-size: 9pt">
Email:<input type="text" name="email" size="14" style="border: 1px solid #0A9EE4">
QQ:<input type="text" name="qq" size="17" style="border: 1px solid #0A9EE4">
MSN:<input type="text" name="msn" size="16" style="border: 1px solid #0A9EE4"></span></td>
</tr>
<tr>
<td width="574" height="40">
<p align="left">
<span style="font-size: 9pt">
邮编:<input type="text" name="post" size="15" style="border: 1px solid #0A9EE4">
通讯地址:<input type="text" name="address" size="37" style="border: 1px solid #0A9EE4"></span></td>
</tr>
<tr>
<td width="574">
<span style="font-size: 9pt">
其它:</span></td>
</tr>
<tr>
<td width="574">
<p align="center">
<span style="font-size: 9pt">
<textarea rows="8" name="other" cols="49" style="border: 1px solid #0A9EE4"></textarea></span></td>
</tr>
<tr>
<td width="574"> </td>
</tr>
<tr>
<td width="574">
<p align="center"><input type="submit" value="提交" name="B1" style="border: 1px solid #156FC7">
<input type="button" value="返回" name="B2" style="border: 1px solid #156FC7" onclick="javascript:location.href='list.jsp';"></td>
</tr>
</table></form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="90"> </td>
</tr>
<tr>
<td width="90" valign="top">
</td>
<td width="588" valign="top">
<%@ include file="copyright.jsp"%>
</td>
<td width="90"> </td>
</tr>
</table>
<p>
</center>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -