<%@ page contentType="text/html; charset=gb2312" language="java"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登录</title>
<script language="javascript">
function IsDigit(cCheck)
{
return (('0'<=cCheck) && (cCheck<='9'));
}
function IsAlpha(cCheck)
{
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
}
function IsValid()
{
var struserName = login.UserName.value;
for (nIndex=0; nIndex<struserName.length; nIndex++)
{
cCheck = struserName.charAt(nIndex);
if (!(IsDigit(cCheck) || IsAlpha(cCheck)))
{
return false;
}
}
return true;
}
function docheck()
{
if(login.UserName.value=="")
{
alert("请填写用户名");
return false;
}
else if(!IsValid())
{
alert("用户名只能使用字母和数字");
return false;
}
else if(login.UserPassword.value=="")
{
alert("请填写密码");
return false;
}
else
{
return true;
}
}
</script>
<STYLE type=text/css>
td, th {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 24px;
color: #333333;
}
</STYLE>
</head>
<body>
<h1 align="center">用户登录</h1>
<div align="center">
<form name="login" action="user_login_check.jsp" method="post" target="_self" onSubmit="return docheck()">
<table width="90%">
<tr>
<td width="50%" align="right" height="25">用户名:</td>
<td width="50%" align="left" height="25"><input type="text" name="UserName"></td>
</tr>
<tr>
<td width="50%" align="right" height="25">密码:</td>
<td width="50%" align="left" height="25"><input type="password" name="UserPassword"></td>
</tr>
</table>
<p>
<input type="submit" name="sub" value="登录">
<input type="reset" name="res" value="重填">
</p>
</form>
</div> </body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登录</title>
<script language="javascript">
function IsDigit(cCheck)
{
return (('0'<=cCheck) && (cCheck<='9'));
}
function IsAlpha(cCheck)
{
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
}
function IsValid()
{
var struserName = login.UserName.value;
for (nIndex=0; nIndex<struserName.length; nIndex++)
{
cCheck = struserName.charAt(nIndex);
if (!(IsDigit(cCheck) || IsAlpha(cCheck)))
{
return false;
}
}
return true;
}
function docheck()
{
if(login.UserName.value=="")
{
alert("请填写用户名");
return false;
}
else if(!IsValid())
{
alert("用户名只能使用字母和数字");
return false;
}
else if(login.UserPassword.value=="")
{
alert("请填写密码");
return false;
}
else
{
return true;
}
}
</script>
<STYLE type=text/css>
td, th {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 24px;
color: #333333;
}
</STYLE>
</head>
<body>
<h1 align="center">用户登录</h1>
<div align="center">
<form name="login" action="user_login_check.jsp" method="post" target="_self" onSubmit="return docheck()">
<table width="90%">
<tr>
<td width="50%" align="right" height="25">用户名:</td>
<td width="50%" align="left" height="25"><input type="text" name="UserName"></td>
</tr>
<tr>
<td width="50%" align="right" height="25">密码:</td>
<td width="50%" align="left" height="25"><input type="password" name="UserPassword"></td>
</tr>
</table>
<p>
<input type="submit" name="sub" value="登录">
<input type="reset" name="res" value="重填">
</p>
</form>
</div> </body>
</html>
解决方案 »
- 急!!Caused by: java.lang.NoClassDefFoundError: javax/xml/rpc/Service
- JSP中如何用combobox显示action返回的list值和指定选择值
- 高手一定要帮忙啊!!!!!!!!!!!!
- 困绕我几天的问题,IIS6.0与Tomcat的整合问题。
- 小妹诚心拜求一位JSP比较有经验的老师,先100分送上,日后还有重谢
- while(rs.next())这个异常处理怎么写
- 数据库查询的问题,急!
- 如何设计Q2Semantic数据库(雪地里跪求)
- 请问在jsp里有没有像asp里的response.end的语句,这样方便调试。解决后马上结贴!
- tomcat 怎么设置servlet?
- jsp 后台类中读取文件路径问题
- the security settings could not be applied to the database!
<%@ page import="java.sql.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户注册</title>
</head>
<body>
<%
String s_Rand_1 = (String)session.getAttribute("rand");
String s_Rand_2 = request.getParameter("Rand");
if (s_Rand_1.equals(s_Rand_2))
{
String strSql="";
String database_username="sa";
String database_password="934072160";
String url="jdbc:sqlserver://localhost:1433;DataBaseName=Message";
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection dbConn= DriverManager.getConnection(url,database_username,database_password);
Statement stmt=dbConn.createStatement();
ResultSet rs=null;
String s_UserName = request.getParameter("UserName");
strSql = "select * from message where UserName like 's_UserName'";
rs = stmt.executeQuery(strSql);
if(rs.next())
{
out.println("<h1 align=center>用户名<font color=red>"+s_UserName+"</font>已经存在!</h1>");
out.println("<div align=center><input type=button name=btn value=返回 onClick='window.history.go(-1)'></div>");
}
else
{
String s_UserPassword = request.getParameter("UserPassword");
String s_NickName = request.getParameter("NickName");
String s_Sex = request.getParameter("Sex");
String s_Email = request.getParameter("Email");
strSql = "insert into message (UserName,UserPassword,NickName,Email) values('"+s_UserName+"','"+s_UserPassword+"','"+s_NickName+"','"+s_Email+"')";
try
{
stmt.executeUpdate(strSql);
out.println("<h1 align=center>用户注册成功,您的注册信息如下</h1>");
out.println("<p align=center>用户名:<font color=blue>"+s_UserName+"</font></p>");
out.println("<p align=center>密码:<font color=blue>"+s_UserPassword+"</font></p>");
out.println("<p align=center>昵称:<font color=blue>"+s_NickName+"</font></p>");
if(s_Sex.equals("0"))
{
out.println("<p align=center>性别:<font color=blue>男</font></p>");
}
else
{
out.println("<p align=center>性别:<font color=blue>女</font></p>");
}
out.println("<p align=center>Email:<font color=blue>"+s_Email+"</font></p>");
}
catch(Exception ex)
{
out.println("<h1 align=center>注册失败</h1>");
out.println("<div align=center><input type=button name=btn1 value=返回 onClick='window.history.go(-1)'></div>");
}
}
rs.close();
stmt.close();
dbConn.close();
}
catch(Exception ex)
{
out.println("<h1 align=center>数据库连接错误</h1>");
}
}
else
{
out.println("<h1 align=center>您输入的验证码错误</h1>");
out.println("<div align=center><input type=button name=btn3 value=返回 onClick='window.history.go(-1)'></div>");
}
%>
</body>
</html>