Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet simple code to login user & authenticate it from database mysql

Have Programming Question? Ask it here!
 
 
 


Prateek Mishra
simple code to login user & authenticate it from database mysql
2 Answer(s)      3 years and a month ago
Posted in : JSP-Servlet


Sir,

I am creating a login page which contain userid & password. Iwant to authenticate user from mysql database.

please tell me the code for it.

Thanks,,


Advertisement
View Answers

July 22, 2011 at 12:46 PM


1)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="Login"></td></tr>
<tr><td></td><td><a href="register.jsp">Register Here</a></td></tr>
</table>
</form>
</html>

2)check.jsp:

<%@page import="java.sql.*"%>
<%
try{
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");
          }
        }
    catch(Exception e){
    System.out.println(e);
}
%>


July 22, 2011 at 12:47 PM


Please go through the following link:

JSP Login Application



Related Tutorials/Questions & Answers:
simple code to login user & authenticate it from database mysql
simple code to login user & authenticate it from database mysql  Sir, I am creating a login page which contain userid & password. Iwant to authenticate user from mysql database. please tell me the code for it. Thanks
How to view database for user when they login in netbeans and mysql?
How to view database for user when they login in netbeans and mysql?  I create a web page where when user login they have to fill in a form, after... but it come out with all the other user information too. I'm using netbeans and mysql
Advertisements
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  ......please help in display details of particular student after he login ...i want to display the details of only current user who logged
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  ... the user information.. now their is a login and registration page for newuser. after the user has filled the form he should go to the welcome page where he
simple code for XML database in JS
simple code for XML database in JS  Sir , i want a code in javascript for XML database to store details (username and password entered by user during registration process (login process)). please send me a code . Thank you
Insert Image into Mysql Database through Simple Java Code
Insert Image into Mysql Database through Simple Java Code... simple java code that how save image into mysql database. Before running this java code you need to create data base and table to save image in same database
Servlet to authenticate user
from the database then client will be entered with authenticate user and password... Servlet to Authenticate User     ...; String url="jdbc:mysql://localhost/jsp?user=root&password=root
Login Authentication in JSP
from the database using MySQL and we are forwarding this servlet data...; For getting values from database we are using MySQL database and connecting... Use of Select Box to show the data from database   
java code for registration and login pages, mysql as a bankend.
java code for registration and login pages, mysql as a bankend.  please send me the java code for registration and login pages and to store the data in mysql
login application
Example Login Authentication using Bean and Servlet In JSP simple code to login user & authenticate it from database mysql Project of a web application...login application  how to create login application ?   Hi
login page using jsp servlrt with mysql database?
login page using jsp servlrt with mysql database?  Description: example:total users are 3.each use have username and password save in mysql database table login. After successfully login user1 see only index page,if user2 login
code for user registration page and login page of emails using jsp
code for user registration page and login page of emails using jsp  hiiiiiii please send me the code for user registration page and login page of email using jsp and servlets and also code for database connectivity to oracle
Spring 3 MVC Login Form Example with Database MySql
Spring 3 MVC Login Form Example with Database MySql  Sir i have checked your project of Spring 3 MVC Login Form Example But Sir Not able to do It with database Mysql. Can you Provide code for login with database. Thanks
Developing Login Action Class
for login action class and database code for validating the user against database... the user id and password from the login form and checks the login id... process. Get the login information from the user Developing Login Action Class
download code from database
download code from database  how to download files from database
Can anybody help me with this simple MySql code
Can anybody help me with this simple MySql code  select c.countryid, r.bp, r.sp, c.country, t.timee from rate as r, countryloc as c, todaysrate as t where r.countryid=t.countryid and t.countryid=c.country this is waht i gt whn
jsp page to add the user to mysql database
jsp page to add the user to mysql database  adduser.jsp: <...;title>Add User</title> </head> <form name="user" action...;tr> <td>User Name</td> <td><input type
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
Simple Login(JSF)
Simple Login(JSF)  I have tried to run the Simple Login code provided using netbeans. It gives me error. CAn I run it using netbeans or need to config anything in order to run the prog
data retrival from database throw simple jsp..
data retrival from database throw simple jsp..  We can retrieve the the data from data base simple jsp page: Jsp Page:retrive.jsp <...; Statement stmt = null; String Query="SELECT * FROM STUD"; try
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql database using php.... below my code is that.. <html> <head>
Data retrieve from mysql database
Data retrieve from mysql database  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list... code retrieves the employee name in the dropdown. When the user selects any name
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database.... Apache Tomcat/6.0.29  We have used MySQl database. 1)page.jsp: <
Submit comments in database when user clicks on submit button
create a database named "usermaster" in MySql and table named "user... Submit comments in database when user clicks on submit button... to show how to submit comments from a jsp page and insert it to the MySql
Retrieve image from mysql database through jsp
to retrieve image from mysql database through jsp code. First create a database... Retrieve image from mysql database through jsp... will be retrieved from database on the basis of  'id' field of the table. So code
@WebServlet Login and Logout Example
simple example which will demonstrate how you can create a login page, how can you authenticate them at the time of login, and finally logged out them in servlet... sql= "SELECT name FROM login WHERE name = '"+name+"'
How to hide HTML code from user? - Security
How to hide HTML code from user?  Hi All, I am trying to provide security to my web application. To achieve this I want to restrict user from... reconstruct your page as well from the code. Look up javascript obfuscation
JSP Login Form with MySQL Database Connection and back end validation
Here we have created a simple login form using MySQL Database Connection... a simple login logout example using JSP. When a user inputs information... to create JSP Login form backed with MySQL database: The following image
Repairing mysql database from command line
Repairing mysql database from command line  Hi, Can anyone tell me the process for repairing mysql database from command line? Thanks
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
simple web appllication to insert, update or display from database - JSP-Servlet
simple web appllication to insert, update or display from database  ... in which we can insert, update or delete data from database. i can also display database content on jsp page. please send complete code. thank you mani saurabh
Spring Security Authorized Access with Customized Login from Database
check user authenticity using customized login from database table(in spring...Spring Security Authorized Access with Customized Login from Database In this section, you will learn about authorized access with customized login from
user in mysql
user in mysql  how to create user in mysql?   Please visit the following link: http://www.roseindia.net/mysql/mysql5/mysql-creating-account.shtml
How to prevent from navigating to ck buttonnext page when user reaches login page using back button
How to prevent from navigating to ck buttonnext page when user reaches login... goback to user login page using back button and agin click browser forward button... document opens..But i dont want it to happen.Instead,it should again ask for login
How to access (MySQL)database from J2ME?
How to access (MySQL)database from J2ME?  I am new to J2ME. I am using NetBeans. Can anyone help me? How to access (MySQL)database from J2ME? ( I search a lot I found that there is need to access database through servlet
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir... that retrieve the integer values from the database and stored in the integer... which is stored in mysql. so to apply some arithmetic operation on it we have
MySql Databse query to fetch results from database
MySql Databse query to fetch results from database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
problem in selecting second arraylist from mysql database
problem in selecting second arraylist from mysql database  Hi... in mysql database. In the below program , i have hard-coded that second list, but i want second list to be dynamic from database. Please, help me out. Thank
Login Form
; Login form in struts: Whenever you goes to access data from database, as a register user you are always asked for the login...(); //Write jdbc code to validate the user against database
login page with mysql using jsp
login page with mysql using jsp  pls i need a sample of login page to check username and password in mysql database. thanks
Spring Security customized login from database
Spring Security customized login from database In this section, you will learn... page but the login is checked from the database table. We have added spring... the authority and login credential from the database table. <?xml version
login for different user in the same page
login for different user in the same page  how can i do the login for different user in the same page throug jsp
login page php mysql example
login page php mysql example  How to create a login page for user in PHP Mysql? Please provide me a complete tutorial. Thanks in Advance
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
Login authentication & mysql - Java Beginners
sample coding for the following scenerio. I need to code authentication for user login I need to create a user account which is the user can register their personal account with the username and password, must save it in database (MySQL
php login and logout code
php login and logout code  Hi, Can anyone share there code for creating a user login and logout page in PHP?or any useful tutorial that can help to create a login and logout application in PHP.. Thanks in Advance
verfication of user login and then redirecting it to user defined page
verfication of user login and then redirecting it to user defined page  hi, i have a login page that..calls the servlet..and i have used redirect() to redirect to a user defined page..but..wen i press the submit button
Spring 4: Login Form using Spring MVC and Hibernate Example
database. Here are we are adding/modifying the code for validating the user against the data stored in the MySQL database server. You can download the code from... to validate the user against database. MySQL database server is used to store
Advertisements
 

 

 

DMCA.com