zoukankan      html  css  js  c++  java
  • 第六周

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ page language="java" import="java.util.*"%>
    <%@ page import ="java.sql.*"%>
    <html>
    <head>
    <title>内容收集界面</title>
    </head>
    <body>
    <%--<%--%>

    <%
    PreparedStatement pre = null;
    Statement sql;
    ResultSet rs;
    request.setCharacterEncoding("utf-8");
    String Name = request.getParameter("uname"); //获取输入的用户名
    String Ps = request.getParameter("upwd"); // 密码
    Name.trim();
    Ps.trim();
    request.setCharacterEncoding("utf-8");

    Class.forName("com.mysql.jdbc.Driver");
    // 建立连接
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?serverTimezone=GMT", "root", "123456");
    sql =conn.createStatement();
    String SQL = "select * from users where uname=? and password=?";
    pre=conn.prepareStatement(SQL);
    pre.setString(1,Name);
    pre.setString(2,Ps);
    rs=pre.executeQuery();
    if (rs.next()) {
    String name = rs.getString(1);
    session.setAttribute("name",name);
    %><p>欢迎登陆:<%=name%></p><%
    }else{%> <p>输入错误,请重新登录</p><a href="register.jsp"><button>返回登录界面</button></a>
    <%
    }
    rs.close();
    sql.close();
    conn.close();
    %>

    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>register</title>
    <style type="text/css" ></style>
    </head>
    <body>
    
    <form action="login.jsp" method="post">
        用户名:<input type="text" name="uname"><br>&nbsp; 码:<input type="password" name="upwd"><br>
        <input type="submit" value="提交">
    </form>
        
    </body>
    </html>

     

  • 相关阅读:
    机器学习: t-Stochastic Neighbor Embedding 降维算法 (二)
    数学辨异 —— 泰勒展开与等比数列求和
    HDU 4705 Y
    C#实现的内存分页机制的一个实例
    java程序获得SqlServer数据表的表结构
    GLSL中的各种变量总结
    HTTP协议学习
    Jedis中的一致性hash
    C语言数据结构----双向链表
    ios7毛玻璃效果实现
  • 原文地址:https://www.cnblogs.com/tianzhiyuan/p/14645855.html
Copyright © 2011-2022 走看看