<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    騎豬闖天下

    J2ME隨筆,記錄成長(zhǎng)的腳步

    統(tǒng)計(jì)

    留言簿(3)

    閱讀排行榜

    評(píng)論排行榜

    [HTML-原創(chuàng)] Web頁(yè)面實(shí)現(xiàn)登錄驗(yàn)證 范例

    Web頁(yè)面實(shí)現(xiàn)登錄驗(yàn)證

    HTML入門(mén)的范例,一句一句敲入的代碼,特此保留,以備查閱。
    騎豬闖天下。

    1. index.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
      
    <head>
        
    <title>系統(tǒng)登錄</title>
        
        
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        
    <meta http-equiv="description" content="this is my page">
        
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        
        
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

      
    </head>
      
      
    <body>
        版權(quán)所有:杜長(zhǎng)風(fēng) 
    <br>
        發(fā)布時(shí)間:20080919
    <br>
        
        
        
    <center>
        
    <h2>系統(tǒng)登錄</h2>
        
    <form action="login.jsp" method="post">
            
    <input type="text" name="uid" maxlength=18 style="width:150"> <br>
            
    <input tpye="password" name="upwd" maxlength=18 style="width:150"> <br>
            
    <input type="submit" value="登錄">
            
    <input type="reset" value="取消">
        
    </form>
        
    </center>
      
    </body>
      
    </html>

    2. login.jsp
    <%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
    <%@ page import="java.sql.*"%>    


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      
    <head>
        
        
    <title>驗(yàn)證頁(yè)面</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">
        
    -->

      
    </head>
      
      
    <body> 
        
    <%
        
    String username = request.getParameter("uid");
        
    String password = request.getParameter("upwd");
        
    if (username != null && !username.equals(""))
        {
            try{
                
    //連接數(shù)據(jù)庫(kù)
                Class.forName(
    "com.mysql.jdbc.Driver"); //注意這里的連接可能有問(wèn)題
                Connection conn 
    = DriverManager.getConnection("jdbc:mysql://localhost/test""root""admin");
                Statement stmt 
    = conn.createStatement();
                
                
    String sql = "select * from user where username='" + username + "'";
                sql 
    += "and password='" + password + "'";
                
                ResultSet result 
    = stmt.executeQuery(sql);
                
    if(result.next())
                {
                    session.setAttribute(
    "login""ok"); //驗(yàn)證通過(guò)后,跳轉(zhuǎn)到后續(xù)界面
                    session.setAttribute(
    "uname", username);
        
    %>
                        
    <jsp:forward page="main.jsp"/>
                        
        
    <%
                }
    else 
                    out.println(
    "錯(cuò)誤的用戶名和密碼");  //驗(yàn)證未通過(guò),顯示錯(cuò)誤信息
                    
                out.println(
    "<a href=index.html>返回</a>");
            }catch(Exception ee){
                ee.printStackTrace();
            }
        }
    else {
            
            out.println(
    "請(qǐng)先登錄!");
            out.println(
    "<a href=index.html>返回</a>");
        }
      
    %>
      
    </body>
    </html>

    3. main.jsp
    <%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      
    <head>
        
        
    <title>主頁(yè)面</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">
        
    -->

      
    </head>
      
      
    <body>
        
    <!-- 包含近來(lái)驗(yàn)證身份頁(yè)面的源代碼 -->
        
    <%@include file="checkvalid.jsp"%>
            歡迎進(jìn)入本頁(yè)面,您已經(jīng)通過(guò)驗(yàn)證,你的用戶名是:
    <%=session.getAttribute("uname")%><p>
                
    <href="continue.jsp"> 你可以跳轉(zhuǎn)到后續(xù)界面</a>
      
    </body>
    </html>

     

    4. checkvalid.jsp

    <%@ page language="java" import="java.util.*"  contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      
    <head>
        
        
    <title>驗(yàn)證頁(yè)面</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">
        
    -->

      
    </head>
      
      
    <body>
        This is my JSP page. 
    <br>
        
    <%
        
    if(session.getAttribute("login"== null || !session.getAttribute("login").equals("ok"))
        {
            
    //檢查未通過(guò),跳轉(zhuǎn)回登錄界面
            response.sendRedirect(
    "index.html");
        }
         
    %>
      
    </body>
    </html>

    5. continue.jsp
    <%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      
    <head>
        
        
    <title>Insert title here</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">
        
    -->

      
    </head>
      
      
    <body>
          
    <center>
        
    <%@include file="checkvalid.jsp" %>
            
    <%=session.getAttribute("uname"%>,歡迎您進(jìn)入第二個(gè)頁(yè)面!<br>
            
    <% out.println("<a href=index.html>返回</a>"); %>
        
    </center>
      
    </body>
    </html>

    posted on 2008-09-20 14:23 騎豬闖天下 閱讀(2294) 評(píng)論(0)  編輯  收藏


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 桃子视频在线观看高清免费完整| 免费在线观看一区| 777爽死你无码免费看一二区| 亚洲精品无码久久久久去q| v片免费在线观看| 成全高清视频免费观看| 亚洲综合无码一区二区三区| 久久亚洲精品无码播放| 一区二区三区免费电影| 国产亚洲精品看片在线观看| 丝袜足液精子免费视频| 亚洲AV日韩AV永久无码绿巨人| 国产精品视频白浆免费视频| 免费a级毛片18以上观看精品| 美女视频黄a视频全免费网站一区| 国产美女精品视频免费观看| 久久精品国产亚洲av麻豆色欲| 亚洲国产高清国产拍精品| 国产一级特黄高清免费大片| 成人午夜免费视频| 毛片基地免费观看| 综合偷自拍亚洲乱中文字幕| 亚洲色偷拍区另类无码专区| 亚洲永久网址在线观看| gogo全球高清大胆亚洲| 三级黄色在线免费观看| 亚洲高清不卡视频| 日韩a在线观看免费观看| 国产免费高清69式视频在线观看| 亚洲国产成人私人影院| 女人张开腿给人桶免费视频| 有色视频在线观看免费高清在线直播| 亚洲成av人影院| 久久WWW免费人成人片| 一区二区在线免费视频| 亚洲视频小说图片| 免费a级毛片视频| 精品一区二区三区免费毛片爱 | 国产亚洲欧洲精品| 黄+色+性+人免费| 成人午夜影视全部免费看|