第十周作业

数据库test 中建个表 stu(stuid 主键 自动增长 ,用户名,密码,年龄)

 

 

1.设计一个注册页面,实现用户注册功能

2.设计一个登陆页面,实现用户名密码登陆

3.两个页面可以互相超链接

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>注册</title>
</head>
<body>
 
<form action="jump.jsp" method="post">
<table>
            <tr>
            <td>用户名</td>
            <td><input type="text" name="uname" /></td>
            </tr>
            <tr>
            <td>密码</td>
            <td><input type="text" name="upwd" /></td>
            </tr>
            <tr>
            <td>年龄</td>
            <td><input type="text" name="uage"/></td>
            </tr>
            <tr>
            <td><input type="submit" value="注册" /></td>
            <td><a href="login.jsp">登录</a></td>
            </tr>
            </table>
        </form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录</title>
</head>
<body>
<form action="judge.jsp" method="post">
            <table>
            <tr>
            <td>用户名</td>
            <td><input type="text" name="uname" /></td>
            </tr>
            <tr>
            <td>密码</td>
            <td><input type="text" name="upwd" /></td>
            </tr>
            <tr>
            <td><input type="submit" value="登录" /></td>
            <td><a href="register.jsp">注册</a></td>
            </tr>
            </table>
</form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  
<%@ page import="dao.StuDao"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>判断</title>
</head>
<body>
    <%
        String uname = request.getParameter("uname");
        String upwd = request.getParameter("upwd");
 
        StuDao s1 = new StuDao();
        if (s1.login(uname, upwd)) {
            request.getRequestDispatcher("true.jsp").forward(request, response);
        } else {
            request.getRequestDispatcher("false.jsp").forward(request, response);
        }
    %>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  
<%@ page import="dao.StuDao"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>跳转</title>
</head>
<body>
    <%
        String uname = request.getParameter("uname");
        String upwd = request.getParameter("upwd");
        String uages = request.getParameter("uage");
 
        int uage = Integer.parseInt(uages);
        StuDao s1 = new StuDao();
        s1.reg(uname, upwd, uage);
        request.getRequestDispatcher("login.jsp").forward(request, response);
    %>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录成功显示</title>
</head>
<body>
    <h1>登录成功!</h1>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录失败显示</title>
</head>
<body>
    <h1>登录失败,3秒后返回登录界面</h1>
    <%
        response.setHeader("refresh", "3;url=login.jsp");
    %>
</body>
</html>

 

 

 

 

 

posted @ 2022-05-07 21:19  潘雨  阅读(11)  评论(0编辑  收藏  举报