Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this is login.jsp:
- <div id="header">
- <h1 align = center><a href = "index.jsp"><img></a></h1>
- <table align = "center" border = "1">
- <tr class = "dimgray">
- <%
- if (session.getAttribute("userName") != null) {
- %>
- <td class = "dimgray"><a href ="index.jsp">Welcome</a></td>
- <% }
- if (session.getAttribute("userName") == null && session.getAttribute("username") == null) {
- %>
- <td class = "dimgray"><a href = "form.jsp">Sign Up</a></td>
- <td class = "dimgray"><a href ="login.jsp">Log In</a></td>
- <td class = "dimgray"><a href ="admin.jsp">Admin Log In</a></td>
- <% }
- if (session.getAttribute("userName") != null) {
- %>
- <td class = "dimgray"><a href ="logout.jsp">Log Out</a></td>
- <% }
- %>
- </tr>
- </table>
- </div>
- <br>
- <form name = "login" action = "loginOperation.jsp">
- <table align = "center">
- <tr>
- <td>
- Username:
- </td>
- <td>
- <input type="text" name="username" size = "25" required>
- </td>
- </tr>
- <tr>
- <td>
- Password:
- </td>
- <td>
- <input type="password" size = "25" name="password" required>
- </td>
- </tr>
- <tr>
- <td></td>
- <td><center><input type="submit" value="Log in" /></center></td>
- </tr>
- </table>
- </form>
- //this is loginOperation.jsp
- <%--
- Document : bdikatAdmin
- Created on : 14/04/2016, 23:20:57
- Author :
- --%>
- <%@page import="MyClasses.MyUtils"%>
- <%@page import="java.sql.ResultSet"%>
- <%@page import="java.sql.Statement"%>
- <%@page import="java.sql.Connection"%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Check for user</title>
- <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
- <style type="text/css">
- .btn {font: 10px Tahoma; font-weight: bold; color: red; background: #ccc; border: 1px solid darkgray; padding: 5px}
- .btn:hover {border: 1px solid black; background: yellow}
- .menuText
- {
- height: 5px;
- color: brown;
- opacity:0.6;
- font-family: sans-serif;
- font-weight: bold;
- font-size: 20px;
- }
- .menuText:hover
- {
- height: 5px;
- color: orange;
- opacity:1.5;
- font-family: sans-serif;
- font-weight: bold;
- font-size: 20px;
- }
- </style>
- <script type="text/javascript">
- function startTime()
- {
- var today=new Date();
- var h=today.getHours();
- var s=today.getSeconds();
- var m=today.getMinutes();
- m=checkTime(m);
- s=checkTime(s);
- document.getElementById('txt').innerHTML=h+":"+m+":"+s;
- t=setTimeout(function(){startTime(),500});
- }
- function checkTime(i)
- {
- if(i<10)
- {
- i="0"+i;
- }
- return i;
- }
- </script>
- </head>
- <body dir="rtl" bgcolor="blanchedalmond" onload="startTime()">
- <div class="black" id="txt" align="left"></div>
- <!--navbar-->
- <div id="navBarWrapper">
- <nav class="navbar navbar-inverse">
- <div class="container-fluid">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="index.jsp">D.I.N Solutions</a>
- </div>
- <div class="collapse navbar-collapse" id="myNavbar">
- <ul class="nav navbar-nav">
- <li><a href="index.jsp">Home</a></li>
- <li class="active"><a href="form.jsp">Registration</a></li>
- <li><a href="products.jsp">Our Products</a></li>
- <li><a href="about.jsp">About</a></li>
- </ul>
- <ul class="nav navbar-nav navbar-right">
- <li><a href="Registration.jsp"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
- <li><a href="login.jsp"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
- </ul>
- </div>
- </div>
- </nav>
- </div>
- <br><br><br>
- <center><b><u><font size="5" color="blue">User access check</font></u></b></center>
- <%
- request.setCharacterEncoding("UTF-8"); //o קידוד לעברית
- String username = request.getParameter("username");
- String password = request.getParameter("password");
- Connection con = MyUtils.getSiteDBconnection(application, "db\\siteDB.mdb");
- Statement stmt = con.createStatement();
- String sql = "SELECT * FROM users WHERE username='" + username + "' And password='" + password + "'";
- ResultSet rs = stmt.executeQuery(sql);
- // out.print(sql + "<br/>Was Done!");
- //o בדיקת קיום n
- if(rs.next())
- {
- session.setAttribute("userName", username);
- response.sendRedirect("login.jsp");
- }
- else
- {
- out.println("<br><br><center><h2>User not allowed</h2></center><br><br><br><br><br><br><br><br>");
- }
- //O סגירת הקשר עם מסד הנתונים
- stmt.close();
- con.close();
- %>
- <a href="login.jsp">Back to user log in</a>
- <br><br><br><br>
- <table align="center" dir="rtl">
- <tr>
- <td>
- <font color="brown" size="5">
- <marquee onmouseover="this.stop()" onmouseout="this.start()" direction="rtl" >Rights reserved Niso 2016</marquee>
- </font>
- </td>
- </tr>
- </table>
- <script type="text/javascript" src="JavaScript/formJS.js" ></script>
- <!--must be included in every page for bootstrap-->
- <!-- jQuery library -->
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
- <!-- Latest compiled JavaScript -->
- <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- </body>
- </html>
- // this is loging.jsp
- <%--
- Document : index
- Created on : 14/04/2016, 21:19:49
- Author :
- --%>
- <%@page import="MyClasses.MyUtils"%>
- <%@page import="java.sql.ResultSet"%>
- <%@page import="java.sql.Statement"%>
- <%@page import="java.sql.Connection"%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>basic form</title>
- </head>
- <body>
- <%
- application.setAttribute("siteCounter", 0);
- response.sendRedirect("index.jsp");
- %>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement