registration form

registration form

Hii.. I have to design one registration page in java that looks like

REGISTER

USERNAME (here i have to check whether username already exists in database) EMAIL ADDRESS (here i have to check whether email address already exists in database) PASSWORD

WORD SUGGESTIONs (here i have to design captcha)

submit (while clicking on submit button i have to send verification mail to the user)

please tell me how could i design that. Please help me asap Thanks a lot

View Answers

March 16, 2011 at 4:32 PM

<p>CreateUser.java:
package saar.etisalat.dao;</p>

<p>import java.io.*;</p>

<p>import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;</p>

<p>import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;</p>

<p>import saar.etisalat.Conn;</p>

<p>public class CreateUser extends HttpServlet {</p>

<pre class="prettyprint">/**
 * 
 */
private static final long serialVersionUID = 1L;

/**
 * Constructor of the object.
 */
public CreateUser() {
    super();
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    CallableStatement callableStatement = null;
    ResultSet resultSet = null;
    ResultSet resultSet1 = null;
    connection = Conn.openConnection();
    String userName = request.getParameter("name");
    String fullName = request.getParameter("fullname");
    String password = request.getParameter("pass");
    String roleid = request.getParameter("sel");
    HttpSession session = request.getSession();
    String sessionUserName = (String) session.getAttribute("sessionUser");
    String userId = null;
    String query = null;
    String dbusername = null;
    try {
        preparedStatement = connection
                .prepareStatement("select user_name from user_details where user_name=?");
        preparedStatement.setString(1, userName);
        System.out.println(userName);
        resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            dbusername = resultSet.getString("user_name");
            System.out.println(dbusername);
        }
        if (dbusername == null) {
            System.out.println("in if");
            query = "{call user_create(?,?,?,?,?,?,0)}";
            callableStatement = connection.prepareCall(query);
            callableStatement.setString(1, userName);
            callableStatement.setString(2, fullName);
            callableStatement.setString(3, roleid);
            callableStatement.setString(4, password);
            callableStatement.setString(5, sessionUserName);
            callableStatement.setString(6, sessionUserName);
            resultSet1 = callableStatement.executeQuery();

            session.setAttribute("name", userName);

            if (session.getAttribute("name") != null) {
                response.sendRedirect("CreateUser.jsp");
            }
        } else if (resultSet != null) {
            System.out.println("in else");
            session.setAttribute("resultSetuser", resultSet);
            if (session.getAttribute("resultSetuser") != null) {
                response.sendRedirect("CreateUser.jsp");
            }
        }

    } catch (SQLException sqlException) {
        sqlException.printStackTrace();
    } finally {
        Conn.closeConnection(resultSet, callableStatement, connection);
    }
}
</code></pre>

<p>}</p>

<p>CreateUser.jsp:
&lt;%@ page language="java"
    import="java.util.<em>,saar.etisalat.</em>,java.sql.*,saar.etisalat.Conn"
    pageEncoding="ISO-8859-1"%>
&lt;%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String name=request.getParameter("name");
%></p>

<p>&lt;%!
    Connection connection = null;
    PreparedStatement preparedStatement = null,preparedStatement1 =null; 
    ResultSet resultSet = null,resultSet1=null;%></p>

<pre class="prettyprint">&lt;%  connection=Conn.openConnection();
    try{
    preparedStatement = connection
            .prepareStatement("select distinct role_name ,role_id  from role order by role_name");
    resultSet = preparedStatement.executeQuery();
</code></pre>

<p> %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Etisalat Login Page</title>
    <meta name="Keywords" content="" />
    <meta name="Description" content="" />
    <link href="styles/styles.css" type="text/css" rel="stylesheet"/>
   <script type="text/javascript">
  function valid()
  {</p>

<pre class="prettyprint">if (document.f1.name.value== "")
{
alert("fill the username");
f1.name.value="";
 f1.name.focus();
 return false;
}


if (document.f1.fullname.value== "")
</code></pre>

<p>{
    alert("Enter fullname");
    f1.fullname.focus();
     return false;
}</p>

<p>   if(document.f1.pass.value=="")
{
     alert("fill the password field");
     f1.pass.focus();
     return false;
}
   if(document.f1.pass.value!=document.f1.cpass.value)
{
      alert("password didnt match");
       f1.pass.focus();
      return false;
}</p>

<p> if ( document.f1.sel.selectedIndex == 0 ) {
  alert ( "Please select role" );
   return false; 
   } </p>

<pre class="prettyprint">return true;
</code></pre>

<p>}</p>

<p>function focuson(){
          document.f1.name.focus();
     }</p>

<p>   </script>
    </head>
        <body class="bodyColor" onload="focuson();"></p>

<pre class="prettyprint">    &lt;p&gt;&lt;table style="margin-top : 100px" align="center" border=0&gt;
        &lt;form name="f1" action="CreateUser" method="post" onsubmit="return valid();"&gt;
          &lt;%if(session.getAttribute("name")!=null)
</code></pre>

<p>{%><td colspan=4>
  &lt;B style="color:teal">User Successfully Created</B></td> &lt;% 
      session.removeAttribute("name");
} %> <br />
&lt;%if(session.getAttribute("resultSetuser")!=null)
{%><td colspan=4>
   &lt;B style="color:red">username already exists select different name</B></td>
        &lt;%   session.removeAttribute("resultSetuser");
} %> <br />
 <div>
   <table border="0" style="width: 96%; border-collapse: collapse"
                    cellpadding="0" align="center">
                    <tr>
                        <td colspan="3">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td class="CC1L"></td>
                        <td class="CC1M">
                            CREATE USER
                        </td>
                        <td class="CC1R"></td>
                    </tr>
                    <tr>
                        <td class="PageBodyL"></td>
                        <td class="PageBodyM">
                            <table>
                                <tr>
                                    <td>
                                            <tr></tr>
                                             <tr></tr>
                                             <tr></tr>
                                             <tr></tr></p>

<pre class="prettyprint">                              &lt;tr&gt;
                    &lt;td class="PageBodyL"&gt;&lt;/td&gt;

                    &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                    &lt;p&gt;&amp;nbsp;&lt;/p&gt;

                    &lt;/td&gt;

                &lt;/tr&gt;
                                    &lt;tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;table border=0 align="center"&gt;
                                         &lt;tr&gt;&lt;td align="left" colspan=2&gt;User Name&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
            &lt;td align="left"&gt;&lt;input type="text" size=30 class="textbox" name="name" /&gt;&lt;/td&gt;
            &lt;tr&gt;&lt;td align="left" colspan=2&gt;Full Name&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
                &lt;td align="left"&gt;&lt;input type="text" size=30 class="textbox" name="fullname" /&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td align="left" colspan=2&gt;Password&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
                &lt;td align="left"&gt;&lt;input type="password" size=30 class="textbox" name="pass" /&gt;&lt;/td&gt;&lt;tr&gt;
            &lt;tr&gt;&lt;td colspan=2 align="left"&gt;Confirm Password&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
                &lt;td align="left"&gt;&lt;input type="password" size=30 class="textbox" name="cpass" /&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td align="left" colspan=2&gt;Role&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
                &lt;td align="left"&gt;&lt;select name="sel" class="dropbox"&gt;
                    &lt;option&gt; -Select- &lt;/option&gt;
                    &lt;%
                        while (resultSet.next()) {
                                String roles = resultSet.getString("role_name");
                                String roleid = resultSet.getString("role_id");
                    %&gt;
                    &lt;option value=&lt;%=roleid%&gt; size=30&gt;&lt;%=roles%&gt;&lt;/option&gt;
                    &lt;%
                        }
                        } catch (SQLException se) {
                            se.printStackTrace();
                        } finally {
                            Conn.closeConnection(resultSet, preparedStatement, connection);
                        }
                    %&gt;
                &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;
                                    &lt;/tr&gt;
                        &lt;td&gt;&lt;/td&gt;

                            &lt;table border=0 align="center"&gt;
                                &lt;tr&gt;
                                    &lt;td&gt;
                                        &lt;input type=submit class="butn" value=Save /&gt;

                                        &lt;input type=reset class="butn" value=Reset /&gt;
                                    &lt;/td&gt;
                                &lt;/tr&gt;
                                &lt;/td&gt;
                                &lt;/tr&gt;
                            &lt;/table&gt;
                    &lt;/td&gt;
                    &lt;td class="PageBodyR"&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td class="PageBodyL"&gt;&lt;/td&gt;
                    &lt;td class="PageBodyM"&gt;
                    &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                    &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                    &lt;/td&gt;
                    &lt;td class="PageBodyR"&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td class="PageBottomL"&gt;&lt;/td&gt;
                    &lt;td class="PageBottomM"&gt;
                        ©SaaR. All rights reserved
                    &lt;/td&gt;
                    &lt;td class="PageBottomR"&gt;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;&lt;/table&gt;

        &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
</code></pre>

<p></html></p>

<p>Here is the code for user already exists...Smilarly check it for the email._ in this is shown as &amp;#95</p>









Related Tutorials/Questions & Answers:
Registration Form
Registration Form  Hi Friends I am Working on a small project.I have to create a Registration page using MVC pattern where i have to insert data username,password,date of birth,Mobile number number into database. How to insert
to creating a registration form
to creating a registration form  how to create a registration form
Advertisements
registration form
registration form  Hii.. I have to design one registration page in java that looks like REGISTER USERNAME (here i have to check whether... style="margin-top : 100px" align="center" border=0&gt; &lt;form
Registration Form in HTML
Registration Form in HTML  User Registration Form in HTML - i wanted to design a user registration form in HTML. So, Can anyone please guide me or give me a peace of code to design a user registration form in HTML. Thanks
Login form and registration
Login form and registration  I need a complete code for ligin and new user registration form and validation
popup registration form
popup registration form  hi i want a code for popup registration form.when user click a button popup form will appear.thanks.
form registration on JavaScript
form registration on JavaScript   i want form of registration on JavaScript > < check the name is string or number & if the name number output error >> and the same of email and birthday and country >> <
JSP code for registration form
JSP code for registration form  Haiiii can u please tell me how to encrypt password field in registration form and to compare both password and confirm password fields using jsp
AJAX REGISTRATION FORM
AJAX REGISTRATION FORM  I have implemented user name, check and state selection using ajax, in the html registration form. I am loading two XML... either username or state. How to implement both in same registration form could any
to create registration form
to create registration form  hello friends,im student and i want to do an assignment on to create an registration form with 20 input fields by using...://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
user Registration form using bean
user Registration form using bean   In this code,password and confirm password does n't matches.Every time an error occured if i entered same string for both.Please help to sort my problem
how to create a user registration form in php
how to create a user registration form in php  how to create a user registration form in php
creating web page for form registration
creating web page for form registration  I am creating web page for form registration to my department ..I have to Reprint the Application Form (i.e Download the PDf File from the Database ) , when the user gives the Application
registration form using oop concept
registration form using oop concept  I would like to write a program student registration form at kindergartens and display the information... the output?   Registration Form: import javax.swing.*; import java.awt.
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I...://www.roseindia.net/struts/hibernate-spring/user-registration-action.shtml
web page for form registration to my department
web page for form registration to my department  I am creating web page for form registration to my department ..I have to Reprint the Application Form (i.e Download the PDf File from the Database ) , when the user gives
Developing User Registration Form
Developing User Registration Form   ... necessary to develop the User Registration Form for our Struts, Hibernate and Spring... how to develop the User Registration Form and related JSP files. This User
database spring registration form
database spring registration form We are going to discuss about  database spring registration form. We have created simple spring registration form... registration form. We have used controller and we are using database
HTML Code for registration form
HTML Code for registration form Here is an example of Registration form using... to register on their website. The registration form is presented to the user where the website input their details and submits the form. Registration form
html code for student registration form
html code for student registration form Here is an example of html code for student registration form. In this example, we have displayed many text fields... in student registration form. If you will not enter value in text field than an error
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml  While running this application on netbeans7.0 , i am getting the following error: message /userregister/ description The requested
HTML(Registration form) to Jsp to stored into MS ACCESS database
HTML(Registration form) to Jsp to stored into MS ACCESS database  i am sending one html file that contain 18 fields these are stored in ms-access database by using jsp code.i want to urgent jsp code. please urgent sir. thank
User Registration Form Using JSP(JspBeans)
User Registration Form Using JSP(JspBeans)  ... of user registration form using jsp. One of the basic programming tactics... Step 1: Create a simple registration form (register.html):      
How to Create Login/ Registration Form using PHP and MYSQL
How to Create Login/ Registration Form using PHP and MYSQL  Hi, I am learning PHP. I have some dilemma how to create a Login Form and make connectivity with HTML page using PHP and MYSQL. Is there any body can guide me
How to Create Student Registration Form with HTML Code?
How to Create Student Registration Form with HTML Code? At present, the concept of online student registration form has emerged as a great relief... will learn to create a student registration form using html code in easy steps
User Registration Form Using JSP(JspBeans) after that how i can insert in database
User Registration Form Using JSP(JspBeans) after that how i can insert in database   User Registration Form Using JSP(JspBeans) after that how i can insert in database
login and registration form using servlet and authentication through mysql
login and registration form using servlet and authentication through mysql  i made a simple login and rgistration form using servlet... help here is my code...plz chk the web.xml file also index.jsp(login form) <
How to insert data into databse by JSP form registration page in netbeans
How to insert data into databse by JSP form registration page in netbeans  ... a student. I have been given a task to create registration page with username & password, & after submitting this form it automatically stores data
Develop user registration form
User Registration Form in JSP     ... registration form which will insert  the entered  data into the database... will be inserted  into the database. Firstly the registration form
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE.... 1)register.jsp <html> <form method="post" action="insert.jsp"> <
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE.... 1)register.jsp <html> <form method="post" action="insert.jsp"> <
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Registration form GUI. public class Register extends javax.swing.JFrame { public
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Registration form GUI. public class Register extends javax.swing.JFrame { public
registration application
registration application  How to develop a registration application in struts which has seperate file for database connection and data checking and form and action
user registration
user registration  hi frnds...am working on a project in JSP.i want to create a user registration form with username,password,mail id and check box option for community selection.once the details are registered i want to save
Registration - Ajax
;hi friend, registration form in jsp function checkEmail(email...; } User registration form...Registration  i want to create a registration page. in which User
form
form   Can I prevent a form from being submitted again
course registration
course registration  project for course registration system in java programming
REGISTRATION OF MBEAN
REGISTRATION OF MBEAN  my question is... i have installed jboss, and created a managed Bean(MBEAN)and provided interface and everything. but i dont know whether the service registerd in jmx or not. please suggest me
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
database connectivity in jsp form
database connectivity in jsp form We are going to create jsp registration form database. We first create simple registration form. All data ... in this form. We can insert, update, delete any data in this form
ModuleNotFoundError: No module named 'registration'
ModuleNotFoundError: No module named 'registration'  Hi, My Python... 'registration' How to remove the ModuleNotFoundError: No module named 'registration' error? Thanks   Hi, In your python
user registration example
user registration example  hello roseindia i'm searching for a user registration application/example using struts can you pls help me
registration key - Java Beginners
registration key  I want the serial key for JCreator Pro 4.50. I lost it. If any body has it please send
Sip Registration - MobileApplications
Sip Registration  I need to registration with sip server using j2me. i use the code of jsr180. but it didnt work. is there any help to register with cordia using j2me? opu
student registration example
visit the following links: http://www.roseindia.net/jsp/user-registration-form...student registration example  1.reg.jsp <%@ page language="java...; <form name="f1" > <form action="Servlet" method="get"> <
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration...;form method="post" name="RForm" onSubmit="return validateForm();"> <
Form Handling in Spring Framework
Form Handling in Spring Framework  I have created spring project.I created the form. When I entered the values to the form, the values should... the program the program is forwarding to another page according to form action
ModuleNotFoundError: No module named 'automatron-registration'
ModuleNotFoundError: No module named 'automatron-registration'  Hi...: No module named 'automatron-registration' How to remove the ModuleNotFoundError: No module named 'automatron-registration' error? Thanks   
ModuleNotFoundError: No module named 'django-registration'
ModuleNotFoundError: No module named 'django-registration'  Hi, My... named 'django-registration' How to remove the ModuleNotFoundError: No module named 'django-registration' error? Thanks   Hi

Ads