重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
加入在frame中的按钮名为sure
站在用户的角度思考问题,与客户深入沟通,找到盐城网站设计与盐城网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站制作、成都网站建设、外贸营销网站建设、企业官网、英文网站、手机端网站、网站推广、主机域名、网页空间、企业邮箱。业务覆盖盐城地区。
Button sure=new Button("确定");
sure.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
frame1.setVisible(false);
Frame frame2=new Frame();
frame2.setVisible(true);
}
});
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
title无标题文档/title
script language="javascript"
function fsubmit(obj)
{
obj.submit();
}
function freset(obj){
obj.reset();
}
/script
/head
body bgcolor="#333333"
form id="form1" name="form1" method="post" action="conn.jsp"
table width="745" border="0" align="center"
tr
td width="100" /td
td /td
td width="104" /td
/tr
tr
td /td
td width="527" height="297" background="img/LoginBg.jpg" bgcolor="#F0F0F0"
table width="358" border="0"
tr
td width="70" height="51" /td
td width="119" /td
td width="160" /td
/tr
tr
td height="46" /td
tdfont color="#FFFFFF"用户名:/font/td
tdinput type="text" name="user" style=" width:160px" id="user" //td
/tr
tr
td height="34" /td
tdfont color="#FFFFFF"密 码:/font/td
tdinput type="password" name="pswd" style="width:160px" id="pswd" //td
/tr
tr
td height="24" /td
td /td
td /td
/tr
/table
table width="396" border="0"
tr
td width="82" height="30" /td
td width="114"img src="img/loginbutton.jpg" style="cursor:hand;" onclick="javascript:fsubmit(document.form1);"/td
td width="41" /td
td width="141"img src="img/canclebutton.jpg" style="cursor:hand;" onclick="javascript:freset(document.form1);"/td
/tr
/table /td
td /td
/tr
tr
td /td
td /td
td /td
/tr
/table
/form
/body
/html
%@ page language="java" import="java.util.*" contentType="text/html;charset=GB2312" import="java.sql.*"%
%@ page import="com.microsoft.sqlserver.jdbc.SQLServerDriver" %
%@page import="java.sql.DriverManager"%
HTML
HEAD
/HEAD
body
%
String userName=request.getParameter("user");
String Pswd =request.getParameter("pswd");
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
}
catch(ClassNotFoundException e)
{
out.print("0");
out.print(e.toString());
}
try
{
Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=RegUser","sa","123");
Statement stmt = con.createStatement();
String sql="select * from tb_user";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
if(userName.equals(rs.getString(2))Pswd.equals(rs.getString(3)))
{
rs.close();
stmt.close();
con.close();
%
jsp:forward page="index.html" /jsp:forward
%
}
}
rs.close();
stmt.close();
con.close();
%
script type="text/javascript"
if(!confirm("用户名或密码错误,是否要转入注册页"))
{
location.href="MyHtml.html";
}
else
{
location.href="Register.html";
}
/script
%
}
catch(Exception e)
{
out.print("1");
out.print(e.toString());
}
%
/body
/HTML
点击进入js,将user和pwd通过ajax调用后台java代码去判断并根据返回值判断正确则window.location.href打开新的页面
!DOCTYPE html
html
head
title登录/title
/head
body
form onsubmit="return check()"
label用户名/labelinput id="username" type="text" name="username"
label密码/labelinput id="password" type="password" name="password"
input type="submit" value="登录"
/form
script type="text/javascript"
function check(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if(!username){
alert("用户名不能为空!");
return false;
}
if(!password){
alert("密码不能为空!");
return false;
}
return true
}
/script
/body
/html