how to create a login page and registration page?

how to create a login page and registration page?

hellow, pls tell me the code for how we can create a login page and registration page and how we can store the info in database.only in advance java as jsp.

View Answers

May 30, 2011 at 10:53 AM

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">New User<a></td></tr>

</table>
</form>
</html>

2)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");
          }
%>

3)register.jsp:

<html>

<form name="form" method="post" action="insertdata.jsp">
<table>
<tr><td>Enter First Name</td><td><input type="text" name="fname"></td></tr>
<tr><td>Enter Last Name</td><td><input type="text" name="lname"></td></tr>
<tr><td>Enter Username</td><td><input type="text" name="uname"></td></tr>
<tr><td>Enter Pasword</td><td><input type="password" name="pass"></td></tr>
<tr><td>Enter Address</td><td><input type="text" name="address"></td></tr>
<tr><td>Enter City</td><td><input type="text" name="city"></td></tr>
<tr><td></td><td><input type="submit" value="Add" name="button"></td></tr>
</table>
</form>
</html>

May 30, 2011 at 10:54 AM

continue....

4)insertdata.jsp:

<%@page import="java.sql.*,java.util.*"%>
<table>
<%
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String uname=request.getParameter("uname");
String pass=request.getParameter("pass");
String address=request.getParameter("address");
String city=request.getParameter("city");
System.out.println(fname+lname+uname+pass+address+city);
        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st=con.createStatement();
        int i=st.executeUpdate("insert into login(firstname,lastname,username,password,address,city) values('"+fname+"','"+lname+"','"+uname+"','"+pass+"','"+address+"','"+city+"')");

        out.println("Data is successfully inserted into database.");

                    con.close();

        }
        catch(Exception e){
        System.out.println(e);
        }
        %>
        </table>









Related Tutorials/Questions & Answers:
how to create a login page and registration page?
java code for registration and login pages, mysql as a bankend.
Advertisements
How to Create Login/ Registration Form using PHP and MYSQL
code for user registration page and login page of emails using jsp
how to create session for login
How to create simple HTML Login Page?
How to create simple HTML Login Page?
RichFaces: Login & Registration Application:
how to create a user registration form in php
How to make Struts Hibernate and Spring Based Login/Registration Application?
Login & Registration - JSP-Servlet
Login form and registration
Login page
php create pages automatically
create login page using data from text file
basic login and registration web page using jsp and servlet without using bean .....
How to retrieve kernal memory details(paged and non-paged ) using SIGAR API in java program
How to Create Student Registration Form with HTML Code?
login page
Login Page
login page in php
how to create a xml page
login page
Spring, Hibernate login and registration application
login page
to create registration form
What is the use of Login Page?
how to create web page on jsp?
login page
static page and dynamic pages?
static page and dynamic pages?
static page and dynamic pages?
How to insert data into databse by JSP form registration page in netbeans
LOGIN PAGE
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?
jsp login page
Struts Hibernate Spring - Login and User Registration - Hibernate
coding for login page
login page - Java Beginners
Create Web Page with jsp
create a login project - Development process
Spring MVC Login Example
How to Create JSP Page
Registration page with JavaScript Validation
Creating Login Page In JSF using NetBeans
How to use filter to redirect to login page after session timeout
How to use filter to redirect to login page after session timeout.
How to use filter to redirect to login page after session timeout.

Ads