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
how to create session for login
How to create simple HTML Login Page?
How to create simple HTML Login Page?
code for user registration page and login page of emails using jsp
how to create a user registration form in php
RichFaces: Login & Registration Application:
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 Create Student Registration Form with HTML Code?
how to create a xml page
How to retrieve kernal memory details(paged and non-paged ) using SIGAR API in java program
login page
login page in php
Login Page
login page
Spring, Hibernate login and registration application
login page
how to create web page on jsp?
to create registration form
How to insert data into databse by JSP form registration page in netbeans
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?
What is the use of Login Page?
static page and dynamic pages?
static page and dynamic pages?
static page and dynamic pages?
login page
How to Create JSP Page
LOGIN PAGE
jsp login page
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.
Struts Hibernate Spring - Login and User Registration - Hibernate
How to prevent from navigating to ck buttonnext page when user reaches login page using back button
How to prevent from navigating to a page after reaching Login page using back button?
coding for login page
login page - Java Beginners
Create Web Page with jsp
create a login project - Development process
Registration page with JavaScript Validation

Ads