Sanddep Roy wrote:I am creating a registration page in jsp,in this page when i register with a email they register sucessfull...but when again i register with same email id it registered.but i want to show it already exist.
this is my question how can i check?..i send my source code....i am creating a registration page in which i wan to validate a email which is already register or not?
here my html code:---<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>regstrtn_1 JSP Page</title>
<script type="text/javascript">
function validate_form()
{
if(document.reg.t1.value=="")
{
alert("Please fill your Name box");
document.reg.t1.focus();
return false;
}
if(!(/^\w+([\-]?\w+)*@\w+([\-]?\w+)*(\.\w{2,3})+$/).test(document.reg.mail.value))
{
alert("You have entered an invalid email address!!")
document.reg.mail.focus();
return false;
}
if(document.reg.t3.value=="")
{
alert("Enter Password");
document.reg.t3.focus();
return false;
}
if((reg.t4[0].checked==false) && (reg.t4[1].checked==false))
{
alert("Please choose your Gender: Male or Female");
return false;
}
}
</script>
</head>
<body style="background-color:skyblue">
<div align="center" style="border-radius:5px">
<fieldset style="height: 400px;width: 350px;background-color: #FF3333;">
<marquee behaviour="scroll" direction="left"> <b><font color="yellow"><H3>Community Forum</H3></font></b>
</marquee>
<form name="reg" method="post" action="db1.jsp" onsubmit="return validate_form()">
<center>
<h2> WELCOME TO OUR REGISTRATION PAGE <h2>
</center>
<table>
<tr>
<td><b>Name:</b></td>
<td><input type="text" name="t1" size="35"></td>
</tr>
<tr>
<td><b>Email:</b></td>
<td><input type="email" name="mail" size="35"></td>
</tr>
<tr>
<td><b>Password:</b></td>
<td><input type="password" name="t3" size="35"></td>
</tr>
<tr>
<td><b>Gender</b></td>
<td><input type="radio" name="t4" value="Male">Male<input type="radio" name="t4" value="female">Female</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td><input type="submit" value="Signup"></td>
<td><a href="login1.html"><input type="button" value="Login"></a></td>
</tr>
</table>
</form>
</fieldset>
</div>
</body>
</html>
then thos is my jsp code:------
<%@page import ="java.sql.*" %>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>db1JSP Page</title>
</head>
<body>
<%
String name =request.getParameter("t1");
String email =request.getParameter("mail");
System.out.println("hhhhh"+ email);
String password =request.getParameter("t3");
String gender =request.getParameter("t4");
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","tiger");
PreparedStatement d= con.prepareStatement("insert into INFO1 values(?,?,?,?)");
d.setString(1,name);
d.setString(2,email);
d.setString(3,password);
d.setString(4,gender);
int i=d.executeUpdate();
if(i>0)
out.println("successfully registered");
response.sendRedirect("login1.html");
}
catch(SQLException e){
out.println(e.getMessage());
}
finally{
//con.close();
out.println(" not successfully registered");
}
%>
</body>
</html>
please respond quickly....its urgent......thnxx in advance....this is the code which i used for checking