zoukankan      html  css  js  c++  java
  • 第七次作业

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    
    <!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=utf-8">
    <title>Insert title here</title>
    <style type="text/css">
    body {
        background-color: azure;
    }
    
    form {
        position: fixed;
        top: 250px;
        left: 650px;
        background-color: #ADD8E6;
        border-radius: 5px;
    }
    
    div {
        font-size: 22px;
        margin-top: 20px;
        padding-left: 40px;
    }
    
    input {
         200px;
        height: 20px;
        border-radius: 5px;
    }
    
    #tj {
         80px;
        height: 30px;
        margin-left: 140px;
        border-radius: 5px;
        font-size: 16px;
        margin-bottom: 20px;
    }
    </style>
    
    </head>
    <body>
        <form action="/school/panduanreg.jsp" method="post">
            <div>
                账 号:    <input type="text" name="username">
            </div>
            <div>
                密 码:    <input type="text" name="password">
            </div>
    
            <div>
                <input type="submit" id="tj" value="注册">
            </div>
        </form>
    
    </body>
    <script type="text/javascript">
    
    </script>
    </html>
    <%@page import="dao.userDao"%>
    <%@page import="bean.user"%>
    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <%
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
        response.setCharacterEncoding("UTF-8");
        HttpSession s = request.getSession();
    
        String username = request.getParameter("username");
        String password1 = request.getParameter("password");
        user u = new user();
        u.setUname(username);
        u.setUpwd(password1);
        userDao ud = new userDao();
        int flag = ud.addUser(u);
        if (flag > 0) {
            out.write("注册成功");
        } else {
            response.sendRedirect("/school/reg.jsp");
        }
    %>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    
    </body>
    </html>
    public int addUser(user u) throws Exception {
            int i = 0;
              Class.forName("com.mysql.jdbc.Driver");
                // 2.提供另外三个连接的基本信息
                String url = "jdbc:mysql://localhost:3306/school";
                String user = "root";
                String password = "root";
                Connection conn = DriverManager.getConnection(url, user, password);
                PreparedStatement ps = conn.prepareStatement("insert into user (uname,upwd)values(?,?)");
                ps.setString(1, u.getUname());
                ps.setString(2, u.getUpwd());
                return i = ps.executeUpdate();
                
        }
    package bean;
    
    public class user {
        private int uid;
        private String uname;
        private String upwd;
        public user() {
            super();
        }
        public user(int uid, String uname, String upwd) {
            super();
            this.uid = uid;
            this.uname = uname;
            this.upwd = upwd;
        }
        public int getUid() {
            return uid;
        }
        public void setUid(int uid) {
            this.uid = uid;
        }
        public String getUname() {
            return uname;
        }
        public void setUname(String uname) {
            this.uname = uname;
        }
        public String getUpwd() {
            return upwd;
        }
        public void setUpwd(String upwd) {
            this.upwd = upwd;
        }
        
        
    }
  • 相关阅读:
    ***mysql索引总结----mysql索引类型以及创建
    XCODE快捷键个人总结
    ios下划线变量:为什么变量前要加下划线才有用?
    ios开发之AppDelegate
    **IOS:xib文件解析(xib和storyboard的比较,一个轻量级一个重量级)
    NEON简介【转】
    NEON在Android中的使用举例【转】
    时钟频率的理解--笔记【原创】
    理解逐次逼近寄存器型ADC:与其它类型ADC的架构对比【转】
    模数转换器(ADC)的基本原理【转】
  • 原文地址:https://www.cnblogs.com/F-dl/p/14680170.html
Copyright © 2011-2022 走看看