寄存器验证不适用于java

时间:2017-08-11 02:49:27

标签: java

   String email = email_register_txt.getText();
   String username = username_register_txt.getText();

   Statement stmt = db_connection.connect().createStatement();

    String sql = "SELECT * FROM user_profile WHERE username=' "+username+" ' OR user_email=' "+email+" ' ";

    res = stmt.executeQuery(sql);

    if(res.next()) {

        if(res.getString("username").equalsIgnoreCase(username)) {
                            JOptionPane.showMessageDialog(registerPanel, "The username has already been already registered!");

        } else if (res.getString("user_email").equalsIgnoreCase(email)) {
                            JOptionPane.showMessageDialog(registerPanel, "This email address has already been already registered!");
    }

} else { ...

当我输入已插入数据库的用户名/电子邮件时,会出现这些错误消息中的任何一个。 我的注册工作,但我认为验证部分可能遗漏了什么?

0 个答案:

没有答案