lOGIN according to der roles

lOGIN according to der roles

how to login a user according to roles and page will should be same content will be different

View Answers

February 21, 2012 at 3:22 PM

1)index.jsp:

<a href="login.jsp">User Login</a>&nbsp&nbsp&nbsp&nbsp<a href="adminPage.jsp">Admin Login</a>

2)login.jsp:

<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
 alert("Enter Username!");
  return false;
}
if(password==""){
 alert("Enter Password!");
  return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>
<%String msg=request.getParameter("msg");
if(msg!=null){
    %>
<label><font color="red"><%=msg%></font></label> 
<%
}
    %>

3)check.jsp:

<%@page import="java.sql.*"%>

<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
 Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+user+"' and password='"+pass+"'");
int count=0;
          while(rs.next())
          {

                   count++;
          }

                    if(count>0)
          {
            out.println("welcome "+user);
          }
          else
          {
                       response.sendRedirect("login.jsp?msg=Invalid Username or Password");
          }
%>

February 21, 2012 at 3:23 PM

continue..

4)adminPage.jsp:

<html>
<title>Admin login Page</title>
<head>
<script language="JavaScript">
function isProper(string) {

if (!string) return false;
var iChars = "*|,\":<>[]{}`\';()@&$#%";

for (var i = 0; i < string.length; i++) {
if (iChars.indexOf(string.charAt(i)) != -1)
return false;
}
return true;
}

function validateForm(theForm){
if(theForm.userid.value==""){
//Please enter accountholder
alert("Enter the User Name.");
theForm.userid.focus();
return false;
}

if (isProper(theForm.userid.value) == false) {
alert("Please enter a valid User Name.");
theForm.userid.focus();
return false;
}

if(theForm.userid.value.length > 20) {
alert("Maximum 20 characters allowed for 'First Name'.")
theForm.userid.focus() ;
return false;
}

if(theForm.password.value==""){
//Please enter accountholder
alert("Enter the password.");
theForm.password.focus();
return false;
}

if (isProper(theForm.password.value) == false) {
alert("Please enter a valid password.");
theForm.password.focus();
return false;
}

if(theForm.password.value.length > 20) {
alert("Maximum 20 characters allowed for 'Password'.")
theForm.password.focus() ;
return false;
}

return true;
}
</script>
</head>
<body>
<H1>Admin login Page</H1>
<form method="POST" action="adminPageAction.jsp" onsubmit="return validateForm(this);">

<table border="1" ALIGN="LEFT" cellspacing="0" cellpadding="0" width="50">
<tr>
<td width="25%"><b>User-Id:</b></td>
<td width="25%">
<input type="text" name="userid" size="20">
</td>
</tr>
<tr>
<td width="25%"><b>Password:</b></td>
<td width="25%">
<input type="password" name="password" size="20">
</td>
</tr>
<tr>
<td>&nbsp</td>
<td>
<input type="submit" name="submit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>

5)adminPageAction.jsp

<%@ page language="java" import="java.sql.*,java.io.UnsupportedEncodingException,java.security.MessageDigest,sun.misc.BASE64Encoder,sun.misc.CharacterEncoder,java.security.MessageDigest" %>


<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String userid=request.getParameter("userid");
String password=request.getParameter("password");

MessageDigest d = MessageDigest.getInstance("SHA");
d.update(password.getBytes("UTF-8"));
byte raw[] = d.digest();
String hash = (new BASE64Encoder()).encode(raw);
System.out.println(hash);

con.close();
out.println("Successfully");
}
catch (SQLException s){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>









Related Tutorials/Questions & Answers:
lOGIN according to der roles
lOGIN according to der roles  how to login a user according to roles...(); ResultSet rs=st.executeQuery("select * from login where username='"+user...: <html> <title>Admin login Page</title> <head> <
User LogIn According to Role
User LogIn According to Role  User login According to role but output will be always displayed in a single page.. but content will change according role
Advertisements
ModuleNotFoundError: No module named 'Der_Entschachtler'
ModuleNotFoundError: No module named 'Der_Entschachtler'  Hi, My... named 'Der_Entschachtler' How to remove the ModuleNotFoundError: No module named 'Der_Entschachtler' error? Thanks   Hi, In your
login
login  How to create login page in jsp
login
login  How to create login page in jsp
login
login  login page display an error showing failure to login even when the correct information is entered
login
login  how to login admin and user with the same fields(name & password) in single login page while the table for admin and user is seprate in database(mysql) please provide me solution
login
login  i want to now how i can write code for form login incolude user and password in Jcreator 4.50   Hello Friend, Visit HereADS_TO_REPLACE_1 Thanks
ModuleNotFoundError: No module named 'roles'
ModuleNotFoundError: No module named 'roles'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'roles' How to remove the ModuleNotFoundError: No module named 'roles'
login
java.awt.event.*; class Login { JButton SUBMIT; JLabel label1,label2; final JTextField text1,text2; Login() { final JFrame f=new JFrame("Login Form...(); ResultSet rs=st.executeQuery("select * from login where username='"+value1
login
login  how to create login page in jsp   Here is a jsp code that creates the login page and check whether the user is valid or not. 1...;tr><td></td><td><input type="submit" value="Login">
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
Version of slide>roles dependency
List of Version of slide>roles dependency
Version of slide>slide-roles dependency
List of Version of slide>slide-roles dependency
ModuleNotFoundError: No module named 'ansible-roles'
ModuleNotFoundError: No module named 'ansible-roles'  Hi, My... 'ansible-roles' How to remove the ModuleNotFoundError: No module named 'ansible-roles' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ansible-roles'
ModuleNotFoundError: No module named 'ansible-roles'  Hi, My... 'ansible-roles' How to remove the ModuleNotFoundError: No module named 'ansible-roles' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django_roles'
ModuleNotFoundError: No module named 'django_roles'  Hi, My Python... 'django_roles' How to remove the ModuleNotFoundError: No module named 'django_roles' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'py-roles'
ModuleNotFoundError: No module named 'py-roles'  Hi, My Python...-roles' How to remove the ModuleNotFoundError: No module named 'py-roles... to install padas library. You can install py-roles python with following
ModuleNotFoundError: No module named 'py-roles'
ModuleNotFoundError: No module named 'py-roles'  Hi, My Python...-roles' How to remove the ModuleNotFoundError: No module named 'py-roles... to install padas library. You can install py-roles python with following
ModuleNotFoundError: No module named 'roles-for-python3'
ModuleNotFoundError: No module named 'roles-for-python3'  Hi, My... named 'roles-for-python3' How to remove the ModuleNotFoundError: No module named 'roles-for-python3' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ansible-roles'
ModuleNotFoundError: No module named 'ansible-roles'  Hi, My... 'ansible-roles' How to remove the ModuleNotFoundError: No module named 'ansible-roles' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django_roles'
ModuleNotFoundError: No module named 'django_roles'  Hi, My Python... 'django_roles' How to remove the ModuleNotFoundError: No module named 'django_roles' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'flask-roles'
ModuleNotFoundError: No module named 'flask-roles'  Hi, My Python... 'flask-roles' How to remove the ModuleNotFoundError: No module named 'flask-roles' error? Thanks   Hi, In your python environment
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
DIFFERENT PAGES FOR DIFFERENT USERS ACCORDING TO THEIR ROLE
DIFFERENT PAGES FOR DIFFERENT USERS ACCORDING TO THEIR ROLE  I HAVE A PROBLEM IN PHP CODING PLS HELP ME PROBLEM IS THAT I WANT DIFFERENT PAGES TO VIEW FOR DIFFERENT USERS WHEN THEY LOGIN ACCORDING TO THEIR ROLE IN DATABASE
Maven Dependency roles >> 2.0
You should include the dependency code given in this page to add Maven Dependency of slide >> roles version2.0 in your project
Maven Dependency roles >> 2.1M1
You should include the dependency code given in this page to add Maven Dependency of slide >> roles version2.1M1 in your project
Version of wicket>wicket-auth-roles dependency
List of Version of wicket>wicket-auth-roles dependency
ModuleNotFoundError: No module named 'ansible-roles-graph'
ModuleNotFoundError: No module named 'ansible-roles-graph'  Hi, My... named 'ansible-roles-graph' How to remove the ModuleNotFoundError: No module named 'ansible-roles-graph' error? Thanks   Hi
ModuleNotFoundError: No module named 'ansible-roles-graph'
ModuleNotFoundError: No module named 'ansible-roles-graph'  Hi, My... named 'ansible-roles-graph' How to remove the ModuleNotFoundError: No module named 'ansible-roles-graph' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-members-roles'
ModuleNotFoundError: No module named 'django-members-roles'  Hi...: No module named 'django-members-roles' How to remove the ModuleNotFoundError: No module named 'django-members-roles' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-members-roles'
ModuleNotFoundError: No module named 'django-members-roles'  Hi...: No module named 'django-members-roles' How to remove the ModuleNotFoundError: No module named 'django-members-roles' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-members-roles'
ModuleNotFoundError: No module named 'django-members-roles'  Hi...: No module named 'django-members-roles' How to remove the ModuleNotFoundError: No module named 'django-members-roles' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-roles-access'
ModuleNotFoundError: No module named 'django-roles-access'  Hi, My... named 'django-roles-access' How to remove the ModuleNotFoundError: No module named 'django-roles-access' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-user-roles'
ModuleNotFoundError: No module named 'django-user-roles'  Hi, My... named 'django-user-roles' How to remove the ModuleNotFoundError: No module named 'django-user-roles' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python3-django-user-roles'
ModuleNotFoundError: No module named 'python3-django-user-roles'  Hi...: No module named 'python3-django-user-roles' How to remove the ModuleNotFoundError: No module named 'python3-django-user-roles' error? Thanks  
ModuleNotFoundError: No module named 'rest-framework-roles'
ModuleNotFoundError: No module named 'rest-framework-roles'  Hi...: No module named 'rest-framework-roles' How to remove the ModuleNotFoundError: No module named 'rest-framework-roles' error? Thanks   Hi
ModuleNotFoundError: No module named 'ansible-roles-graph'
ModuleNotFoundError: No module named 'ansible-roles-graph'  Hi, My... named 'ansible-roles-graph' How to remove the ModuleNotFoundError: No module named 'ansible-roles-graph' error? Thanks   Hi
ModuleNotFoundError: No module named 'custom-user-roles'
ModuleNotFoundError: No module named 'custom-user-roles'  Hi, My... named 'custom-user-roles' How to remove the ModuleNotFoundError: No module named 'custom-user-roles' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-members-roles'
ModuleNotFoundError: No module named 'django-members-roles'  Hi...: No module named 'django-members-roles' How to remove the ModuleNotFoundError: No module named 'django-members-roles' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-rest-framework-roles'
ModuleNotFoundError: No module named 'django-rest-framework-roles'  ...: No module named 'django-rest-framework-roles' How to remove the ModuleNotFoundError: No module named 'django-rest-framework-roles' error? Thanks
ModuleNotFoundError: No module named 'django-roles-access'
ModuleNotFoundError: No module named 'django-roles-access'  Hi, My... named 'django-roles-access' How to remove the ModuleNotFoundError: No module named 'django-roles-access' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-user-roles'
ModuleNotFoundError: No module named 'django-user-roles'  Hi, My... named 'django-user-roles' How to remove the ModuleNotFoundError: No module named 'django-user-roles' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'flask_basic_roles'
ModuleNotFoundError: No module named 'flask_basic_roles'  Hi, My... named 'flask_basic_roles' How to remove the ModuleNotFoundError: No module named 'flask_basic_roles' error? Thanks   Hi, In your
login page
login page  code for login page
change color according to the database value
change color according to the database value  any one know how to get values from database ( 1 or 0 ) and according to that change the color ( red or green) of given list

Ads