zoukankan      html  css  js  c++  java
  • 邮箱

    添加注册功能

    register&doregister

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>register</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
        <style type="text/css">
        body{font-size:20px;}
        </style>
        <script type="text/javascript">
        function mycheck(){
        if(form1.userName.value==""){
        alert("用户名不能为空,请输入用户名");
        form1.userName.focuse();
        return;
        }
        if(form1.password.value==""){
        alert("密码不能为空,请输入密码");
        form1.password.focus();
        return;
        }
        if(form1.validationCode.value==""){
        alert("验证码不能为空,请输入验证码");
        form1.validationCode.focus();
        return;
        }
        if(form1.validationCode.value!=form1.validationCode1.value){
        alert("请输入正确的验证码");
        form1.validationCode.focus();
        return;
        }
        form1.submit1();
        }
        </script>
      </head>
      
      <body>
       <form action="doregister.jsp" name="form1" method="post">
       用户名:<input type="text" name="userName" size="20"><br>
       密   码:
       <input type="password" name="password" size="20"><br>
       验证码:<input type="text" name="validationCode" onKeyDown="if(event.keyCode==13){form1.submit.focus();}"size="6">
      <%
      int intmethod1=(int)((((Math.random())*5))+1);
      int intmethod2=(int)((((Math.random())*5))+1);
      int intmethod3=(int)((((Math.random())*5))+1);
      int intmethod4=(int)((((Math.random())*5))+1);
      
      String intsum=intmethod1+""+intmethod2+intmethod3+intmethod4;
       %> 
       <input type="hidden" name="validationCode1" value="<%=intsum%>">
       <img style="height:20px;weight:20px" src="images/<%=intmethod1 %>.png">
       <img style="height:20px;weight:20px" src="images/<%=intmethod2 %>.png">
       <img style="height:20px;weight:20px" src="images/<%=intmethod3 %>.png">
       <img style="height:20px;weight:20px" src="images/<%=intmethod4 %>.png">
       <br>
       <input type="submit" name="submit1" value="注册" onClick="mycheck()">
        
       <input type="reset" value="重置">
       </form>
        
         <br>
      </body>
    </html>
    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <%@page import="java.sql.SQLException"%>
    <%@page import="dao.BaseDao"%>
    <%@page import="entity.Msg"%>
    <%@page import="java.sql.DriverManager"%>
    <%@page import="java.sql.PreparedStatement"%>
    <%@page import="java.sql.ResultSet"%>
    <%@page import="java.util.Random"%>
    <%@page import="java.sql.Connection"%>
    <!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>doregister</title>
    </head>
    <body>
        <%
        request.setCharacterEncoding("utf-8");
        String username = request.getParameter("userName");
        String password = request.getParameter("password");
        Random r = new Random();
        String email = r.nextInt(100)+ r.nextInt(100)+"@qq.com";     
       try {
                // 1.加载驱动
                Class.forName("com.mysql.jdbc.Driver");
                // 2.建立连接
                Connection con = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/email", "root", "ROOT");
                // 3.编写SQL语句
                String sql = "insert into users(username,password,email) values(?,?,?)";            
                PreparedStatement ps = con.prepareStatement(sql);// PS是用来执行SQL语句和给问号赋值的
                ps.setString(1, username);
                ps.setString(2, password);
                ps.setString(3, email);
                
                
                // 4.执行SQL语句
                ps.executeUpdate();            
                // 执行查询
                // 5.处理查询结果(查询的时候需要)
                // 6.关闭连接
                ps.close();
                con.close();
    
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
    
    %>
        注册成功
        </br>
        <a href="index.jsp">【返回】 
    </body>
    </html>

    用郭德纲账号登陆并发邮箱

    退出登录,用赵启伯账号查看邮件

  • 相关阅读:
    11.14 mii-tool:管理网络接口的状态
    11.15 dmidecode:查询系统硬件信息
    11.11 ntsysv:管理开机服务
    HDU 2476 String painter 刷字符串(区间DP)
    HDU 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)
    母函数的应用
    HDU 1028 Ignatius and the Princess III伊格和公主III(AC代码)母函数
    HDU 1059 Dividing 分配(多重背包,母函数)
    HDU 2955 Robberies抢劫案(01背包,变形)
    HDU 1011 Starship Troopers星河战队(树形dp)
  • 原文地址:https://www.cnblogs.com/zhaoqibo1701121/p/12922848.html
Copyright © 2011-2022 走看看