There is a registration form on my web application. What I want is, when a user submits the form, validation should be done to check if the email id which the user entered already exists or not in the database. And accordingly, if it exists then a message like in a snackbar should appear saying, the email id already exists. If it's a new email, then it will redirect to the success page.
Following is my checkData method where I am just checking if when I enter the email id on the form, it exists or not, but the ouput is always "value not found".
public void checkData() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname?autoReconnect=true&useSSL=FALSE", "root", "pwd");
st = con.createStatement();
String query1 = "select email from users where email='" +email99+ "'";
ResultSet rs = st.executeQuery(query1);
if(rs.next()) {
System.out.println("Success");
}
else {
System.out.println("Value not found");
}
rs.close();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}
}
Note:- My main concern is email validation.
Thank you