Results 1 to 2 of 2
  1. #1
    aiesha is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Default Check the values and try again... ...

    I have a tiny problem....hope you guys can help me .....after I fill the form I get
    "Check the values and try again... " and when I check my database no information has been inserted.....

    The form is to add a new user
    Java Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>New Account Creation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script language="JavaScript">
    var no="0123456789"
    function validateForm()
    {
    	if(document.form1.cmb_acc.value=="false")
    	{
    		alert("Select a value");
    		document.form1.cmb_acc.focus();
    		return false;
    	}
    	else if (document.form1.cmb_acc.value=="1")
    	{
    			if(!validate(Trim(document.form1.txt_accno.value),no))
    			{
    				document.form1.txt_accno.focus();
    				alert("Enter the valid account number");
    				return false;
    			}
    			if(!validate(Trim(document.form1.txt_crd.value),no))
    			{
    				document.form1.txt_crd.focus();
    				alert("Enter the valid card number");
    				return false;
    			}
    			if(Trim(document.form1.txt_accno.value)=="")
    			{
    				document.form1.txt_accno.focus();
    				alert("Enter the valid account number");
    				return false;
    			}
    			if(Trim(document.form1.txt_crd.value)=="")
    			{			
    				document.form1.txt_crd.value=0;
    			}
    	}
    	else
    	{
    		document.form1.txt_accno.value=0;
    		document.form1.txt_crd.value=0;
    	}
    	
    	for(i=3;i<=6;i++)
    	{	
    		if (Trim(document.form1.elements[i].value)=="")
    		{
    			document.form1.elements[i].focus();
    			alert("Enter a value");
    			return false;
    		}
    	}
    	if(document.form1.cmb_sex.value=="false")
    	{
    		alert("Select a value");
    		document.form1.cmb_sex.focus();
    		return false;
    	}
    	for(i=8;i<=12;i++)
    	{	
    		if (Trim(document.form1.elements[i].value)=="")
    		{
    			document.form1.elements[i].focus();
    			alert("Enter a value");
    			return false;
    		}
    	}
    	if(document.form1.cmb_bra.value=="false")
    	{
    		alert("Select a value");
    		document.form1.cmb_bra.focus();
    		return false;
    	}	
    	if(Trim(document.form1.txt_age.value)=="false")
    	{
    		alert("Select a value");
    		document.form1.txt_age.focus();
    		return false;
    	}	
    	if(document.form1.cmb_tst.value=="false")
    	{
    		alert("Select a value");
    		document.form1.cmb_tst.focus();
    		return false;
    	}
    	if(document.form1.cmb_tsp.value=="false")
    	{
    		alert("Select a value");
    		document.form1.cmb_tsp.focus();
    		return false;
    	}
    	if(Trim(document.form1.txt_pwd.value)=="false")
    	{
    		alert("Enter the country");
    		document.form1.txt_pwd.focus();
    		return false;
    	}
    	
    	var email=document.form1.txt_email.value;
    	var at=email.indexOf('@');
    			
    	if (at == -1 )
    	{
    		alert("Email id not a valid one");
    		document.form1.txt_email.focus();
    		return false;
    	}
    	else if (email.indexOf('@',at+1) != -1)
    	{
    		alert("Email id not a valid one");
    		document.form1.txt_email.focus();
    		return false;		
    	}
    	at=email.indexOf('.',at+1);
    	if (at == -1 )
    	{
    		alert("Email id not a valid one");
    		document.form1.txt_email.focus();
    		return false;
    	}
    	
    	var le=email.length;
    	
    	if (email.charAt(le-1)=='.')
    	{
    		alert("Email id not a valid one");
    		document.form1.txt_email.focus();
    		return false;	
    	}
    	
    	if(!validate(Trim(document.form1.txt_rp.value),no))
    	{
    		document.form1.txt_rp.focus();
    		alert("Enter the valid phone number");
    		return false;
    	}
    	
    	if(!validate(Trim(document.form1.txt_op.value),no))
    	{
    		document.form1.txt_op.focus();
    		alert("Enter the valid phone number");
    		return false;
    	}	
    	if(!validate(Trim(document.form1.txt_age.value),no))
    	{
    		document.form1.txt_age.focus();
    		alert("Enter the valid age");
    		return false;
    	}
    	
    	document.form1.txt_sq.value=Trim(document.form1.txt_sq.value);
    	document.form1.txt_sa.value=Trim(document.form1.txt_sa.value);
    	document.form1.txt_fn.value=Trim(document.form1.txt_fn.value);
    	document.form1.txt_sn.value=Trim(document.form1.txt_sn.value);
    	document.form1.txt_email.value=Trim(document.form1.txt_email.value);
    	document.form1.txt_hname.value=Trim(document.form1.txt_hname.value);
    	document.form1.txt_rp.value=Trim(document.form1.txt_rp.value);
    	document.form1.txt_op.value=Trim(document.form1.txt_op.value);
    	document.form1.txt_city.value=Trim(document.form1.txt_city.value);
    	document.form1.txt_age.value=Trim(document.form1.txt_age.value);
    	document.form1.txt_pwd.value=Trim(document.form1.txt_pwd.value);
    	document.form1.txt_accno.value=Trim(document.form1.txt_accno.value);
    	document.form1.txt_crd.value=Trim(document.form1.txt_crd.value);
    
    	return true;
    }
    function sta()
    {
    	document.form1.cmb_acc.focus()
    }
    </script>
    
    <script language="JavaScript" src="../eBankscripts/usefun.js"></script>
    
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="sta()">
    <form name="form1" method="post" action="new_ant.jsp" onSubmit="return validateForm()">
      <table width="779" border="0" cellpadding="0" cellspacing="0" bgcolor="#D7EADF">
        <!--DWLayoutTable-->
        <tr> 
          <td width="77" height="19">&nbsp;</td>
          <td width="60">&nbsp;</td>
          <td width="181">&nbsp;</td>
          <td width="149">&nbsp;</td>
          <td width="170">&nbsp;</td>
          <td width="43">&nbsp;</td>
          <td width="99">&nbsp;</td>
        </tr>
        <tr> 
          <td height="30"></td>
          <td></td>
          <td colspan="3" valign="top"><img src="tit_apy_new_user.gif" width="500" height="30"></td>
          <td>&nbsp;</td>
          <td></td>
        </tr>
        <tr> 
          <td height="10"></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr> 
          <td height="19"></td>
          <td colspan="2" valign="top"><a onClick="window.open('ter&con.html','','width=549,height=456')" 
    	   href="new_user.html"> 
            <u>
              <font color="#0000CC">Terms and Conditions</font> 
            </u>
            </a></td>
          <td>&nbsp;</td>
          <td colspan="2" valign="top"><div align="right"><font color="#CC3300">* 
              indicates mandatory fields</font></div></td>
          <td></td>
        </tr>
        <tr> 
          <td height="4"></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr> 
          <td height="866"></td>
          <td colspan="5" valign="top"> <table width="100%" height="790" border="1" cellpadding="0" cellspacing="0" bgcolor="#ded7bd">
              <!--DWLayoutTable-->
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"> <font color="#CC3300" face="Times New Roman, Times, serif">&nbsp;</font></td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="right"><font color="#CC3300" face="Times New Roman, Times, serif"><strong>Are 
                    you an account holder ?*</strong></font></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <div align="left"> 
                    <select name="cmb_acc" size="1" id="cmb_acc" >
                      <option value="false" selected>--Select Please--</option>
                      <option value="1">Yes</option>
                      <option value="0">No</option>
                    </select>
                  </div></td>
              </tr>
              <tr bgcolor="#efefe0"> 
                <td height="8" colspan="4" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"><font color="#CC3300"></font></div>
                  <div align="right"><strong><font color="#CC3300">Credit Card Number</font></strong> 
                  </div></td>
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"><strong></strong></div>
                  <div align="left"> 
                    <input name="txt_crd" type="text" id="txt_crd" maxlength="20">
                  </div></td>
              </tr>
              <tr> 
                <td height="5" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="right"><font color="#CC3300"><strong>Account 
                    Number</strong></font></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <input name="txt_accno" type="text" id="txt_accno"> 
                </td>
              </tr>
              <tr> 
                <td height="11" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="right"><strong><font color="#CC3300">Secreat 
                    Question*</font></strong></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <input name="txt_sq" type="text" id="txt_sq" size="45"></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="right"><strong><font color="#CC3300">Answer*</font></strong></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <input name="txt_sa" type="text" id="txt_sa" size="45"></td>
              </tr>
              <tr> 
                <td height="10" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"><div align="right"><strong><font color="#CC3300">First 
                    Name*</font></strong></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <input name="txt_fn" type="text" id="txt_fn2"></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"><strong></strong></div>
                  <div align="right"><font color="#CC3300"><strong>Last Name*</strong></font> 
                  </div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"><font color="#CC3300"></font></div>
                  <div align="left"> 
                    <input name="txt_sn" type="text" id="txt_sn">
                  </div></td>
              </tr>
              <tr> 
                <td height="10" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"><div align="right"><strong><font color="#CC3300">Sex*</font></strong></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <select name="cmb_sex" size="1" id="select2">
                    <option value="false" selected>--Select Please--</option>
                    <option value="Male">Male</option>
                    <option value="Female">Female</option>
                  </select></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"><strong></strong></div>
                  <div align="right"><strong><font color="#CC3300">Email*</font></strong> 
                  </div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"><strong></strong></div>
                  <div align="left"> 
                    <input name="txt_email" type="text" id="txt_email">
                  </div></td>
              </tr>
              <tr> 
                <td height="10" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="right"><strong><font color="#CC3300">Residence 
                    Phone*</font></strong></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <input name="txt_rp" type="text" id="txt_rp"></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"></div>
                  <div align="center"></div>
                  <div align="right"><strong><font color="#CC3300">Office Phone*</font></strong> 
                  </div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <div align="left"><strong></strong></div>
                  <div align="left"> 
                    <input name="txt_op" type="text" id="txt_op">
                  </div></td>
              </tr>
              <tr> 
                <td height="10" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"><div align="right"><strong><font color="#CC3300">House 
                    address *</font></strong></div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <input name="txt_hname" type="text" id="txt_hname"></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top" bgcolor="#ded7bd"> <div align="center"><strong></strong></div>
                  <div align="right"><strong><font color="#CC3300">City*</font></strong> 
                  </div></td>
                <td colspan="2" valign="top" bgcolor="#ded7bd"> <div align="left"><strong></strong></div>
                  <div align="left"> 
                    <input name="txt_city" type="text" id="txt_city">
                  </div></td>
              </tr>
              <tr> 
                <td height="10" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top"><div align="right"><font color="#CC3300"><strong>Bank 
                    Branch*</strong></font></div></td>
                <td colspan="2" valign="top"><select name="cmb_bra" id="select3">
                    <option value="false" selected>--Select Please--</option>
                    <option value="George Town">George Town</option>
                    <option value="Kuala Lumpur">Kuala Lumpur</option>
                    <option value="Ipoh">Ipoh</option>
                    <option value="Kuching">Kuching</option>
                    <option value="Johor Bahru">Johor Bahru</option>
                    <option value="Kota Kinabalu">Kota Kinabalu</option>
                    <option value="Shah Alam">Shah Alam</option>
                    <option value="Malacca Town">Malaca Town</option>
                    <option value="Alor Setar">Alor Setar</option>
                    <option value="Miri">Miri</option>
                    <option value="Petaling Jaya">Petaling Jaya</option>
                    <option value="Kuala Terengganu">Kuala Terengganu</option>
                    <option value="George Town">George Town</option>
                  </select></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top"> <div align="center"><font color="#CC3300"></font></div>
                  <div align="right"><font color="#CC3300"><strong>Age*</strong></font> 
                  </div></td>
                <td colspan="2" valign="top"> <div align="left"><font color="#CC3300"></font></div>
                  <div align="left"> 
                    <input name="txt_age" type="text" id="txt_age">
                  </div></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top"><div align="right"><font color="#CC3300"><strong>Convenient 
                    time to contact you between*</strong></font></div></td>
                <td colspan="2" valign="top"> <div align="left"> 
                    <select name="cmb_tst" size="1" class="inputbox" id="select">
                      <option value="false" selected>--Select Please--</option>
                      <option value="9 AM">9 AM</option>
                      <option value="10 AM">10 AM</option>
                      <option value="11 AM">11 AM</option>
                      <option value="12 PM">12 PM</option>
                      <option value="1 PM">1 PM</option>
                      <option value="2 PM">2 PM</option>
                      <option value="3 PM">3 PM</option>
                      <option value="4 PM">4 PM</option>
                      <option value="5 PM">5 PM</option>
                      <option value="6 PM">6 PM</option>
                      <option value="7 PM">7 PM</option>
                    </select>
                    <strong><font color="#CC3300">and</font></strong> 
                    <select name="cmb_tsp" size="1" class="inputbox" id="cmb_tsp">
                      <option value="false" selected>--Select Please--</option>
                      <option value="10 AM">10 AM</option>
                      <option value="11 AM">11 AM</option>
                      <option value="12 PM">12 PM</option>
                      <option value="1 PM">1 PM</option>
                      <option value="2 PM">2 PM</option>
                      <option value="3 PM">3 PM</option>
                      <option value="4 PM">4 PM</option>
                      <option value="5 PM">5 PM</option>
                      <option value="6 PM">6 PM</option>
                      <option value="7 PM">7 PM</option>
                    </select>
                  </div></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td height="27" colspan="2" valign="top"><div align="right"><strong><font color="#CC3300">State*</font></strong></div></td>
                <td colspan="2" valign="top"> <input name="txt_pwd" type="text" id="txt_pwd"></td>
              </tr>
              <tr> 
                <td height="21" colspan="4" valign="top" bgcolor="#efefe0"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
              <tr> 
                <td width="167" height="27" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
                <td width="123" height="27" valign="top"><div align="center"> 
                    <input type=submit name="Submit" value="Submit" >
                  </div></td>
                <td width="142" height="27" valign="top"><div align="center"> 
                    <input type="reset" name="Reset" value="Reset">
                  </div></td>
                <td width="161" height="27" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              </tr>
            </table></td>
          <td bgcolor="#D7EADF">&nbsp;</td>
        </tr>
        <tr> 
          <td height="34"></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    after submitting the code I get this "Check the values and try again... ..."
    Java Code:
    <html>
    <head>
    </head>
    <%@ page contentType="text/html;" language="java" import="java.sql.*" errorPage="" %>
    <%
    Connection con=null;
    Statement smt=null;
    ResultSet rs=null;
    try
    {
    	Class.forName("com.mysql.jdbc.Driver");
    	con=DriverManager.getConnection("jdbc:mysql://localhost:3306/ebanking","root","aiesha");
    }
    catch(ClassNotFoundException ce){out.println("Check the values and try again...");}
    catch(SQLException ce){out.println("Check the values and try again...");}
    
    smt=con.createStatement();
    rs=smt.executeQuery("select max(req_id) from ant_req");
    int id;
    if(!rs.next())
    {
    	id=0;
    	
    }
    
    else
    {
    	id=rs.getInt(1);
    }
    
    id=id+1;
    int accexi=Integer.parseInt(request.getParameter("cmb_acc"));
    //int accno=Integer.parseInt();
    //int crd=Integer.parseInt(request.getParameter("txt_crd"));
    String sqtn=request.getParameter("txt_sq");
    String sans=request.getParameter("txt_sa");
    String fname=request.getParameter("txt_fn");
    String sname=request.getParameter("txt_sn");
    String sex=request.getParameter("cmb_sex");
    String emailid=request.getParameter("txt_email");
    //long rphone=Long.valueOf(request.getParameter("txt_rp"));
    //long ophone=Long.valueOf(request.getParameter("txt_op"));
    String hname=request.getParameter("txt_hname");
    String city=request.getParameter("txt_city");
    String branch=request.getParameter("cmb_bra");
    int age=Integer.parseInt(request.getParameter("txt_age"));
    String stime=request.getParameter("cmb_tst");
    String sptime=request.getParameter("cmb_tsp");
    String tpwd=request.getParameter("txt_pwd");
    int st=1;
    String query="insert into ant_req values(" + id + "','" + accexi + "','"+ request.getParameter("txt_accno") + "','" + request.getParameter("txt_crd") + "','" + sqtn + "','" + sans + "','" + fname + "','" + sname + "','" + sex  + "','" + emailid  + "','" + request.getParameter("txt_rp")  + "','" + request.getParameter("txt_op")  + "','" + hname  + "','" + city  + "','" + branch  + "'," + age  + ",'" + stime + "','" + sptime  + "','" + tpwd + "'," + st + ")";
    
    try
    {
    	smt.executeUpdate(query);
    }
    catch(SQLException ce){ 
    	out.println("Check the values and try again...");
    	smt.close();
    	con.close();
    }
    smt.close();
    con.close();
    //response.sendRedirect("new_wel.htm");
    %>
    <body onload=window.open("new_wel.html");>
    						</body>
    </html>
    I also get a simple html welcoming window saying thank you for registering....but when I check my database no input has been inserted and I cant login in.....could anyone help me?

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    1.) Do yourself a favour and stop mixing Java with HTML. Put Java code in servlets and helper classes and use the JSP for presentation only.
    2.) Don't do
    Java Code:
    out.println("Check the values and try again...");
    in all your catch blocks.
    An exception is happening and you can't tell where it's happening because all your catch blocks are saying the same thing. Better put messages that let you know the source of the problem and/or just put e.printStackTrace(); so that the full details of the exception are logged.

Similar Threads

  1. Replies: 14
    Last Post: 01-22-2011, 02:36 PM
  2. Loop through array and check values...
    By Spinalkord in forum New To Java
    Replies: 1
    Last Post: 10-24-2010, 10:17 AM
  3. question on how to check values before storing
    By SMHouston in forum New To Java
    Replies: 19
    Last Post: 09-21-2009, 10:54 PM
  4. Replies: 0
    Last Post: 05-22-2008, 10:53 AM
  5. Replies: 0
    Last Post: 11-30-2007, 11:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •