form fields.
Expand|Select|Wrap|Line Numbers
- Name
Again i need to check whether email address already taken or not.
All the Error messages should display as a in this page and then i can pass it back to HTML page using responseText;
I can check the email id from the table and here after i can't find out a way to do next validations. please help.
Expand|Select|Wrap|Line Numbers
- <%@ page language="java" import="java.sql.*" %>
- <%@ include file="../config/conn.jsp" %>
- <%
- String driver = mysql_driver;
- Class.forName(driver).newInstance();
- Connection con=null;
- ResultSet rst=null;
- Statement stmt=null;
- int count;
- String db_email=null;
- String name=request.getParameter("c_name");
- String email=request.getParameter("c_email");
- try
- {
- String url=mysql_con_string;
- con=DriverManager.getConnection(url);
- stmt=con.createStatement();
- }
- catch(Exception e)
- {
- out.println(e.getMessage());
- }
- if(request.getParameter("c_submit") != null)
- {
- rst=stmt.executeQuery("select c_email from clients where c_email ='"+email+"'");
- while(rst.next())
- {
- db_email = rst.getString("c_email");
- if (email.equals(db_email))
- {
- out.println("<font face=\"verdana\" size=\"2\" color=\"red\"><b>Already Taken</b></font>");
- break;
- }
- }
- //Inserting Records
- if(db_email==null)
- {
- count = stmt.executeUpdate("insert into clients(c_name,c_email) values('"+name+"','"+email+"')");
- if(count == 1)
- {
- rst=stmt.executeQuery("select c_name from clients where c_email ='"+email+"'");
- while(rst.next())
- {
- out.println("<B>"+rst.getString("c_name")+"</B>"+" Client Registerd:::");
- }
- }
- }
- }
- else
- {
- out.println("<font face=\"verdana\" size=\"2\" color=\"red\"><b> UnAuthorized Access !</b></font>");
- }
- %>