Within my application, there is an option for users to deactivate their profiles, which can only be reactivated by the admin.
I have created a class called ActivateProfile
with two methods:
userExist(userName)
to check if a user with the given userName exists and if their profile is deactivated- and
activateAccountByUser(userName)
to reactivate the user's profile
When I trigger a JavaScript function on the click event of a button input, it runs smoothly on Chrome and Mozilla, however, I encounter an error on Internet Explorer:
SCRIPT438: Object doesn't support property or method userExist
function activateProf() {
var userName=document.getElementById("userName").value;
if (userName == "") {
alert("Field is mandatory");
} 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");
}
}});
}
}
Below is the code for the ActivateProfile class:
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 {
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;
}