Advertisement
Guest User

Untitled

a guest
May 22nd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //this is login.jsp:
  2.  <div id="header">
  3.  
  4.         <h1 align = center><a href = "index.jsp"><img></a></h1>
  5.  
  6.         <table align = "center" border = "1">
  7.  
  8.             <tr class = "dimgray">
  9.  
  10.                 <%
  11.  
  12.                     if (session.getAttribute("userName") != null) {
  13.  
  14.                 %>
  15.  
  16.                 <td class = "dimgray"><a href ="index.jsp">Welcome</a></td>
  17.  
  18.                 <%                        }
  19.  
  20.                     if (session.getAttribute("userName") == null && session.getAttribute("username") == null) {
  21.  
  22.                 %>
  23.  
  24.                 <td class = "dimgray"><a href = "form.jsp">Sign Up</a></td>
  25.  
  26.                 <td class = "dimgray"><a href ="login.jsp">Log In</a></td>
  27.  
  28.                 <td class = "dimgray"><a href ="admin.jsp">Admin Log In</a></td>
  29.  
  30.                 <%                        }
  31.  
  32.                     if (session.getAttribute("userName") != null) {
  33.  
  34.                 %>
  35.  
  36.                 <td class = "dimgray"><a href ="logout.jsp">Log Out</a></td>
  37.  
  38.                 <%                        }
  39.  
  40.                 %>
  41.  
  42.             </tr>
  43.  
  44.         </table>
  45.  
  46.     </div>      
  47.     <br>
  48.  
  49.     <form name = "login" action = "loginOperation.jsp">
  50.  
  51.         <table align = "center">
  52.  
  53.  
  54.  
  55.             <tr>
  56.  
  57.                 <td>
  58.  
  59.                     Username:
  60.  
  61.                 </td>
  62.  
  63.                 <td>
  64.  
  65.                     <input type="text" name="username" size = "25" required>
  66.  
  67.                 </td>
  68.  
  69.             </tr>
  70.  
  71.             <tr>
  72.  
  73.                 <td>
  74.  
  75.                     Password:
  76.  
  77.                 </td>
  78.  
  79.                 <td>
  80.  
  81.                     <input type="password" size = "25" name="password" required>
  82.  
  83.  
  84.  
  85.                 </td>
  86.  
  87.             </tr>
  88.  
  89.             <tr>
  90.  
  91.                 <td></td>
  92.  
  93.                 <td><center><input type="submit" value="Log in" /></center></td>
  94.  
  95.             </tr>
  96.  
  97.         </table>
  98.  
  99.     </form>
  100. //this is loginOperation.jsp
  101. <%--
  102.     Document   : bdikatAdmin
  103.     Created on : 14/04/2016, 23:20:57
  104.     Author     :
  105. --%>
  106.  
  107. <%@page import="MyClasses.MyUtils"%>
  108. <%@page import="java.sql.ResultSet"%>
  109. <%@page import="java.sql.Statement"%>
  110. <%@page import="java.sql.Connection"%>
  111. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  112.  
  113. <html>
  114.     <head>
  115.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  116.         <title>Check for user</title>
  117.         <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  118.         <style type="text/css">
  119.            .btn {font: 10px Tahoma; font-weight: bold; color: red; background: #ccc; border: 1px solid darkgray; padding: 5px}
  120.            .btn:hover {border: 1px solid black; background: yellow}
  121.            .menuText
  122.             {
  123.                 height: 5px;
  124.                 color: brown;
  125.                 opacity:0.6;
  126.                 font-family: sans-serif;
  127.                 font-weight: bold;
  128.                 font-size: 20px;
  129.             }
  130.             .menuText:hover
  131.             {
  132.                 height: 5px;
  133.                 color: orange;
  134.                 opacity:1.5;
  135.                 font-family: sans-serif;
  136.                 font-weight: bold;
  137.                 font-size: 20px;
  138.             }
  139.     </style>
  140.      <script type="text/javascript">
  141.             function startTime()
  142.             {
  143.                 var today=new Date();
  144.                 var h=today.getHours();
  145.                 var s=today.getSeconds();
  146.                 var m=today.getMinutes();
  147.                 m=checkTime(m);
  148.                 s=checkTime(s);
  149.                 document.getElementById('txt').innerHTML=h+":"+m+":"+s;
  150.                 t=setTimeout(function(){startTime(),500});
  151.             }
  152.             function checkTime(i)
  153.             {
  154.                if(i<10)
  155.                    {
  156.                        i="0"+i;
  157.                    }
  158.                    return i;
  159.             }
  160.         </script>
  161.     </head>
  162.     <body dir="rtl" bgcolor="blanchedalmond" onload="startTime()">
  163.         <div class="black" id="txt" align="left"></div>
  164.             <!--navbar-->
  165.         <div id="navBarWrapper">
  166.             <nav class="navbar navbar-inverse">
  167.             <div class="container-fluid">
  168.               <div class="navbar-header">
  169.                 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
  170.                   <span class="icon-bar"></span>
  171.                   <span class="icon-bar"></span>
  172.                   <span class="icon-bar"></span>
  173.                 </button>
  174.                 <a class="navbar-brand" href="index.jsp">D.I.N Solutions</a>
  175.               </div>
  176.               <div class="collapse navbar-collapse" id="myNavbar">
  177.                         <ul class="nav navbar-nav">
  178.                             <li><a href="index.jsp">Home</a></li>
  179.                             <li class="active"><a href="form.jsp">Registration</a></li>
  180.                             <li><a href="products.jsp">Our Products</a></li>
  181.                             <li><a href="about.jsp">About</a></li>
  182.                         </ul>
  183.                         <ul class="nav navbar-nav navbar-right">
  184.                             <li><a href="Registration.jsp"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
  185.                             <li><a href="login.jsp"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
  186.                         </ul>
  187.                     </div>
  188.                 </div>
  189.             </nav>
  190.         </div>
  191.             <br><br><br>
  192.                            <center><b><u><font size="5" color="blue">User access check</font></u></b></center>
  193.         <%
  194.             request.setCharacterEncoding("UTF-8");  //o קידוד לעברית
  195.  
  196.             String username = request.getParameter("username");
  197.             String password = request.getParameter("password");
  198.  
  199.             Connection con = MyUtils.getSiteDBconnection(application, "db\\siteDB.mdb");
  200.             Statement stmt = con.createStatement();
  201.  
  202.             String sql = "SELECT * FROM users WHERE username='" + username + "' And password='" + password + "'";
  203.             ResultSet rs = stmt.executeQuery(sql);
  204.       //      out.print(sql + "<br/>Was Done!");
  205.  
  206.              //o בדיקת קיום n
  207.             if(rs.next())
  208.                     {
  209.                         session.setAttribute("userName", username);
  210.                         response.sendRedirect("login.jsp");
  211.  
  212.                     }
  213.                     else
  214.                     {
  215.                          out.println("<br><br><center><h2>User not allowed</h2></center><br><br><br><br><br><br><br><br>");
  216.                          
  217.                     }
  218.  
  219.             //O סגירת הקשר עם מסד הנתונים
  220.             stmt.close();
  221.             con.close();
  222.            
  223.  
  224.         %>
  225.         <a href="login.jsp">Back to user log in</a>
  226.         <br><br><br><br>
  227.         <table align="center" dir="rtl">
  228.          <tr>
  229.           <td>
  230.            <font color="brown" size="5">
  231.            <marquee onmouseover="this.stop()" onmouseout="this.start()" direction="rtl" >Rights reserved Niso 2016</marquee>
  232.            </font>
  233.           </td>
  234.          </tr>
  235.         </table>
  236.                 <script type="text/javascript" src="JavaScript/formJS.js" ></script>
  237.         <!--must be included in every page for bootstrap-->
  238.         <!-- jQuery library -->
  239.         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  240.         <!-- Latest compiled JavaScript -->
  241.         <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  242.  
  243.     </body>
  244. </html>
  245. // this is loging.jsp
  246. <%--
  247.     Document   : index
  248.     Created on : 14/04/2016, 21:19:49
  249.     Author     :
  250. --%>
  251.  
  252. <%@page import="MyClasses.MyUtils"%>
  253. <%@page import="java.sql.ResultSet"%>
  254. <%@page import="java.sql.Statement"%>
  255. <%@page import="java.sql.Connection"%>
  256. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  257.  
  258. <html>
  259.     <head>
  260.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  261.         <title>basic form</title>
  262.     </head>
  263.     <body>
  264.       <%
  265.          application.setAttribute("siteCounter", 0);
  266.          response.sendRedirect("index.jsp");
  267.       %>
  268.     </body>
  269. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement