Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I'am trying to implement a system log in where it checks even the cases of the letters in passwords and username, for example if the username saved on the database was account_name; then the user cannot log in when he/she enters ACCOUNT_NAME as his/her username same with password.

Please help me, here's my code:

on VB page

VB
If blUser.checkLogin(txtUN.Text, txtPW.Text) = True Then
               Dim idUser As Integer
               idUser = blUser.UserID
               Response.Cookies("UserID").Value = Convert.ToString(idUser)
               Response.Cookies("UserType").Value = Convert.ToString(blUser.UserType)
               Response.Cookies("FirstName").Value = Convert.ToString(blUser.FirstName)
               Response.Cookies("SchoolOfficeID").Value = Convert.ToString(blUser.SchoolOfficeID)
               Response.Cookies("Password").Value = Convert.ToString(blUser.Password)

               Response.Redirect("~/Transactions03.aspx")


on BL

VB
public Boolean checkLogin(string UserName, string Password)
       {
           DataTable exiting;
           DAUsers daUser = new DAUsers();
           exiting = daUser.loginCheckDA(UserName, Password);
           if (exiting.Rows.Count > 0)
           {
               UserID = Convert.ToInt32(exiting.Rows[0]["UserID"].ToString());
               UserType = exiting.Rows[0]["UserType"].ToString();
               LastName = exiting.Rows[0]["LastName"].ToString();
               FirstName = exiting.Rows[0]["FirstName"].ToString();
               MiddleName = exiting.Rows[0]["MiddleName"].ToString();
               SchoolOfficeID =Convert.ToInt32( exiting.Rows[0]["SchoolOfficeID"].ToString());
               return true;
           }else{
               return false;
           }
       }


on DA

VB
public DataTable loginCheckDA(string username, string password)
        {
            string sql = "SELECT * FROM UserAccount WHERE AccntStatus like 'Active' AND UserName like '" + username + "' AND Password like '" + password + "'";
            DataTable dt =  GetDataTable(sql, null);            
                return dt;         
        }
Posted
Updated 12-Sep-13 4:09am
v2
Comments
Richard C Bishop 12-Sep-13 10:07am    
Why not just make sure they enter valid data and use TOUPPER() or TOLOWER() to negate the case sensitivity?
timJosh 12-Sep-13 10:18am    
No because I'm using a format which is lastname first letter to upper case + "_" + firstname whose 1st letter is still n upper case
Maciej Los 12-Sep-13 10:44am    
Why do you want to change capitalization? It makes no sense at all.
timJosh 12-Sep-13 11:17am    
No I just wanted to have a more tight way of letting the user log in which is by requiring the user to enter exact(I mean even the cases) info.

You can use this tip. ;)

[Here :D]
 
Share this answer
 
Comments
timJosh 12-Sep-13 14:19pm    
This actually works tnx alot :D
gaga blues 12-Sep-13 14:22pm    
Glad to help ;)
You're making a couple of monsterous mistakes in your design. The first of which is storing user passwords in clear text in your database.

The second mistake is using string concatenation to build your SQL query.

Think about this one: What if a user typed
whocares; DROP TABLE UserAccount; --
into the Username box?? I'll give you a hint: You'd be terminated on the spot. Don't think it'll happen?? Think again. It only has to happen once.

Read these[^] and these[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900