Results 1 to 11 of 11

Thread: Mysql Login System - Auto Login Help?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    38

    Mysql Login System - Auto Login Help?

    Hello, I have made my login form that connects to a Mysql database to see if the details that you typed in are correct, and thats all working but I need help creating a option using a checkbox to Automatically login when the form loads. Here is my login code:
    Code:
                Button1.Text = "Loading..."
                Mysqlconnection = New MySqlConnection
                Mysqlconnection.ConnectionString = "server=;Port=3306; user id=; password=; database="
                Mysqlconnection.Open()
    
                Dim Myadapter As New MySqlDataAdapter
                Dim sqlquary = "SELECT * From Users WHERE Username='" & TextBox1.Text & "' AND Password ='" & TextBox2.Text & "';"
                Dim Command As New MySqlCommand
                Command.Connection = Mysqlconnection
                Command.CommandText = sqlquary
                Myadapter.SelectCommand = Command
                Dim MyData As MySqlDataReader
                MyData = Command.ExecuteReader
                If MyData.HasRows = 0 Then
                    Label4.Text = "Login Failed"
                    Button1.Text = "Login"
                Else
                    Form2.Show()
                    Me.Hide()
                End If
            End If

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: Mysql Login System - Auto Login Help?

    Ummm ok so whats the problem you're having with your attempts at auto-login ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    38

    Re: Mysql Login System - Auto Login Help?

    Quote Originally Posted by Niya View Post
    Ummm ok so whats the problem you're having with your attempts at auto-login ?
    I dont know how to setup Auto-Login. I tried one way but when the form loads it opens then closes and shows back up in 20 seconds. Can you provide a solution to my problem (code)?

  4. #4
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: Mysql Login System - Auto Login Help?

    if I understand this right you could have say a checkbox1 that if ticked would log in automatically then in the form load event

    Code:
    if checkbox1.checked = true then
    'all your code
    end if
    if its not checked then they must push the button

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: Mysql Login System - Auto Login Help?

    What form closes and shows back up in 20 seconds ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    38

    Re: Mysql Login System - Auto Login Help?

    Quote Originally Posted by bensonsearch View Post
    if I understand this right you could have say a checkbox1 that if ticked would log in automatically then in the form load event

    Code:
    if checkbox1.checked = true then
    'all your code
    end if
    if its not checked then they must push the button
    I tried this, like i said recently, The login form needs to atleast show up before it automatically logs in, because that code logs in before the login form even shows up (annoying).

  7. #7

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    38

    Re: Mysql Login System - Auto Login Help?

    Quote Originally Posted by Niya View Post
    What form closes and shows back up in 20 seconds ?
    The login form if I try to obove code that benson gave (I tried it before he posted it)

  8. #8

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    38

    Re: Mysql Login System - Auto Login Help?

    Quote Originally Posted by Niya View Post
    What form closes and shows back up in 20 seconds ?
    The login form if I try the above code that benson gave (I tried it before he posted it)

  9. #9
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: Mysql Login System - Auto Login Help?

    Quote Originally Posted by pancakesplatter View Post
    I tried this, like i said recently, The login form needs to atleast show up before it automatically logs in, because that code logs in before the login form even shows up (annoying).
    Ok so when do you wish it to automatically run then? You could put a timer on the form. Stick your code into the tick event and set to 1 second. Then in form load start the timer (and stop it under the tick event as well so only fires once)

    Otherwise the user would have to press or do something

  10. #10
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,836

    Re: Mysql Login System - Auto Login Help?

    As a side note that mechanism is just screaming "SQL injection attack!". Try this as the username:

    ' or 1 = 1 --

    -- is the start of a comment in MS SQL. I don't know what it is for MySQL.

    and you are in. That is one reason you will see so many posts about parameterized SQL here. Do a search on the forum for it. Also here is a basic article on SQL injection attacks to give you an idea of what I'm talking about.

    http://en.wikipedia.org/wiki/SQL_injection
    Last edited by TysonLPrice; Nov 28th, 2012 at 07:58 AM.

  11. #11

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    38

    Re: Mysql Login System - Auto Login Help?

    Hey, got the Auto-Login workiing but whenever I have Auto Login Checked it loads form2 but then lags like crazy. When ever I just click the Login button there is no lag, Can anybody tell me a solution to fix this?

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