//index.htm
<html>
<head>
<title>智能导航系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<script language="javascript">
function chkVal()
{
if(document.form1.user.value==null||document.form1.user.value=="")
{
alert("用户名不得为空!");
document.form1.user.focus();
return false;
}
if(document.form1.psw.value==null||document.form1.psw.value=="")
{
alert("密码不得为空!");
document.form1.psw.focus();
return false;
}
}
</script>
</head>
<body bgcolor="#CCFFCC" text="#666600" link="#009900" vlink="#006600" alink="#00FF00">
<table align="center" valign="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<h1> </h1>
<h1> </h1>
<h1> </h1>
<h1 style="color:blue" align="center">基于GIS的智能导航系统</h1>
</td>
</tr>
<tr>
<td> <h5 style="color:blue" align="right">上海交通大学</h5> </td>
</tr>
<tr>
<td>
<form name="form1" method="post" action="checkLogin.jsp" onsubmit="return chkVal()">
<p align="center">用户名:<input type="text" name="user" size="20"> </p>
<p align="center">密 码: <input type="password" name="psw" size="20"> </p>
<p align="center">
<input type="submit" value="提交">
<input type="reset" value="重新填写"> <a href="manage_add.html">注册</a>
</p>
</form>
</td>
</tr>
</table>
</body>
</html>
//checkLogin.jsp
<html>
<head><title>登陆验证</title></head></html>
//manage_add.html
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>添加用户信息</title>
<style type="text/css">
<!--
.style3 { font-size: xx-large;
font-family: "楷体_GB2312";
}
-->
</style>
<script language="javascript">
function chkVal()
{
if(document.form1.user.value==null||document.form1.user.value=="")
{
alert("用户名不得为空!");
document.form1.user.focus();
return false;
}
if(document.form1.psw.value==null||document.form1.psw.value=="")
{
alert("密码不得为空!");
document.form1.psw.focus();
return false;
}
if(document.form1.email.value==null||document.form1.email.value=="")
{
alert("邮箱不得为空!");
document.form1.psw.focus();
return false;
}
}
</script>
</head>
<body bgcolor="#CCFFCC" text="#666600" link="#009900" vlink="#006600" alink="#00FF00">
<form name="form1" method="POST" action="manage_add_post.jsp" onsubmit="return chkVal()">
<div align="center">
<table width="400" border="0">
<tr>
<h1> </h1>
<h1> </h1>
<h1 style="color:blue" align="center">基于GIS的智能导航系统</h1>
</tr>
<tr>
<td> <h5 style="color:blue" align="right">上海交通大学--陈昉晟制作</h5> </td>
</tr>
</table>
<p> </p>
<table width="46%" height="357" border="1" id="table1">
<tr>
<td colspan="2"><p align="center" class="style3">添加个人信息</td>
</tr>
<tr>
<th width="205" scope="col"> <p align="right">name:</th>
<th width="341" scope="col">
<div align="center">
<input name="user" type="text" id="user" value="" size="25">
</div>
</th>
</tr>
<tr>
<th width="205" scope="col"> <p align="right">password:</th>
<th width="341" scope="col">
<div align="center">
<input name="psw" type="password" id="psw" value="" size="25">
</div>
</th>
</tr>
<tr>
<th width="205"scope="col"><p align="right">email:</th>
<th width="341"scope="col">
<div align="center">
<input name="email" type="text" id="email" value="" size="25">
</div>
</th>
</tr>
<tr>
<td colspan="2">
<p align="center">
<input type="submit" value="提交" name="B1">
<input type="reset" value="重置" name="B2"> <a href="index.htm">返回</a>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
//manage_add_post.jsp
<html>
<head><title>注册信息</title></head>
<%@ page language="java" contentType="text/html;charset=GBK" import="java.sql.*"%>
<body bgcolor="#CCFFCC" text="#666600" link="#009900" vlink="#006600" alink="#00FF00">
<div align="center">
<%
request.setCharacterEncoding("gb2312");
String getUser=request.getParameter("user");
String getPsw=request.getParameter("psw");
String getEmail=request.getParameter("email");
out.print(getUser);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dbpath=request.getRealPath(".")+"/data/map.mdb";
String accessurl="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+dbpath;
Connection con=DriverManager.getConnection(accessurl);
Statement sta=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);//定义发送SQL语句的对象
ResultSet rs=null;//定义指针对象rs
rs=sta.executeQuery("select * from accounts where user='"+getUser+"' and psw='"+getPsw+"'");//发送SQL语句并将执行结果返回给指针对象rs
if(rs.next())//如果找到用户名和密码匹配的记录
{
out.print("用户名已经存在,请重新<a href='manage_add.html'>注册</a>");
rs.close();
}
else
{
rs.close();
sta.close();
sta=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="insert into accounts( user,psw,email) values('"+getUser+"','"+getPsw+"','"+getEmail+"')";
sta.executeUpdate(sql);
out.print("用户注册成功,<a href='index.htm'>返回登陆页面</a>");
}
sta.close();
con.close();
}
catch(Exception e)
{
out.println("异常:"+e);
}
%>
</div>
</body>
</html>