technohead
Technical User
hi i want to do an if statement here so that if the password matches that that was entered then redirect the user to a certain page, which i have done. how do i i do an else part of the statement to say if its not the same print out sorry, wrong password. i have these returning variables to a servlet. im also not sure if i have the return statement in the rigth place cos its giving me back null.
thanks.
public String getType(String CustomerName, String CustomerPwd)
{
if(userPwd.equals(CustomerPwd))
{
try
{
String userType;
con = dbcon.getConnection();
String sql = ("Select ut_userType from userTable where ut_userName = '"+CustomerName+"' and ut_password = '"+CustomerPwd+"'"
Statement stat = con.createStatement();
ResultSet rs1 = stat.executeQuery(sql);
while(rs1.next())
{
userType = rs1.getString("ut_userType"
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
return userType;
}
thanks.
public String getType(String CustomerName, String CustomerPwd)
{
if(userPwd.equals(CustomerPwd))
{
try
{
String userType;
con = dbcon.getConnection();
String sql = ("Select ut_userType from userTable where ut_userName = '"+CustomerName+"' and ut_password = '"+CustomerPwd+"'"
Statement stat = con.createStatement();
ResultSet rs1 = stat.executeQuery(sql);
while(rs1.next())
{
userType = rs1.getString("ut_userType"
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
return userType;
}