我在我的应用程序的选项,用户可以取消他们的个人资料。 只有管理员可以重新激活它们。
我有一个类ActivateProfile
两种方法
-
userExist(userName)
,检查是否存在使用该用户名的用户和他/她的个人资料被停用 - 和
activateAccountByUser(userName)
即再次激活用户的配置文件
我呼吁输入型按钮的单击事件的JavaScript函数。 此代码适用于Chrome和Mozilla的罚款,但在Internet Explorer上我得到这个错误:
SCRIPT438:对象不支持属性或方法userExist
function activateProf() {
var userName=document.getElementById("userName").value;
if (userName == "") {
alert("Полето е задолжително");
} else {
alert(userName + "1");
ActivateProfile.userExist(userName, { callback:function(exist) {
if (userName) {
ActivateProfile.activateAccountByUser(userName);
alert("User is activated");
} else {
alert("User does not exist");
}
}});
}
}
下面是激活型材类的代码
public void activateAccountByUser(String userName) {
try {
Connection c = DBComm.getInstance().getConnection();
Statement s = c.createStatement();
ResultSet set = s.executeQuery("select * from accounts where userName = '" + userName + "' and isauthorized='2'");
if (set.next()) {
Statement st = c.createStatement();
st.executeUpdate("update accounts set isauthorized='1' where userName='" + userName + "' and isauthorized='2'");
}
s.close();
c.close();
} catch (Exception ex) {
java.util.logging.Logger.getLogger(ActivateProfile.class.getName()).log(Level.SEVERE, null, ex);
}
}
public boolean userExist(String userName) throws SQLException {
//true exist
//false does not exist
boolean existEmbg = false;
try {
Connection c = DBComm.getInstance().getConnection();
Statement s = c.createStatement();
ResultSet set = s.executeQuery("select * from accounts where userName = '" + userName + "' and isauthorized='2'");
if (set.next()) {
existEmbg = true;
} else {
existEmbg = false;
}
s.close();
c.close();
} catch (Exception ex) {
java.util.logging.Logger.getLogger(ActivateProfile.class.getName()).log(Level.SEVERE, null, ex);
}
return existEmbg;
}