Results 1 to 7 of 7

Thread: whats wrong with my functions? [resolved]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152

    Resolved whats wrong with my functions? [resolved]

    Okay, im not going to go into every aspect of the program but here goes:

    I've written 2 functions on my serverside which checks a username list for a match n if it finds it then it goes to the 2nd function which then checks if the password in the other listbox matches whats in the database aswell.

    now on my client end , its waiting to receive a "failed" , "1" ,or "2" string back... i know the problem lies in my loginCheck1 function. but say that the login fails due to incorrect username it sends failed twice and then a 1 because maybe the password matches..no clue how this happens seeing as how it shouldn't even go to loginCheck2 if check1 doesnt succeed.

    VB Code:
    1. Private Function loginCheck1()
    2. Dim i As Integer
    3. Dim userName As String
    4. Dim IntList As Integer
    5. userName = Text1 'the username attempting to login
    6. For i = 0 To List2.ListCount - 1
    7. If InStr(userName, List2.List(i)) Then ' check database list for username
    8. 'do whatever you need here.....if it finds the name
    9. IntList = i
    10. List3.Text = List3.List(IntList) 'get corresponding pass next to username
    11. loginCheck2 ' send to logincheck2 function to check if password matches too
    12. Exit For 'exit for if found
    13. Else
    14. 'send back message saying incorrect username/password
    15. server.senddata "failed"
    16. End If
    17. Next
    18. End Function
    19.  
    20. Private Function loginCheck2()
    21. Dim strLogin As String
    22. Dim userPass As String
    23. userPass = Text2
    24. 'check to see if the password matches whats in the database under that username
    25. If List3.Text = userPass Then
    26. 'it matches, do stuff here
    27. strLogin = "1"
    28. server.SendData strLogin
    29. List1.AddItem server.RemoteHostIP & " has logged in successfully! at: " & Now
    30. Else
    31. strLogin = "2"
    32. server.SendData strLogin
    33. End If
    34. End Function

    and heres the client end

    VB Code:
    1. Private Sub client_DataArrival(ByVal bytesTotal As Long)
    2. Dim strLogin As String
    3. ' do stuff to verify if login was successful
    4. client.GetData strLogin
    5. Text1.Text = strLogin
    6. If strLogin = "1" Then
    7. MsgBox "You have logged in successfully! Welcome to the Valeo Chat System...", vbInformation, "Valeo System"
    8. budlist.Show 'since they've logged in correctly, load buddylist lol =D
    9. ElseIf strLogin = "2" Then
    10. MsgBox "Sorry, but your login attempt has failed due to an incorrect username/password!", vbCritical, "Login Failed"
    11. client.Close ' close connection to server
    12. End If
    13. End Sub

    im sure im just not seeing something obvious though,
    Last edited by ice_531; Dec 30th, 2004 at 01:51 AM.
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width