Visual C++ Tutorial 5 -Windows Forms Application: Create Login Form with MySql Part 2




Login Program for C++ with Mysql c++ program to connect to mysql php login code mysql Login Source Codes create login page contain user id,password …

Original source


9 responses to “Visual C++ Tutorial 5 -Windows Forms Application: Create Login Form with MySql Part 2”

  1. can you make a Set of video tutorial about, Visual C++2008 connected to SQL SERVER 2008?, Including SHOW DATA, ADD NEW, EDIT, DELETE, RETRIEVE PICTURES from SQL Server, ADD and DELETE PICTURES TO DATABASE, VIDEOS FROM SQL Server ……………………………………………………………………………………………………………………………………………………………………………………………………………………..
    we'll be thankful if you do. Students from the Philippines 😀

  2. I am a beginner in dotNET. however, I know how to program in PHP and Java and Tcl/Tk with MySQL and Sqlite. and I know standard C++. but what I aim to say is that, you could have used the connection string for a user log-in. I did it myself and it works just fine. This is the code snippet to get it done.

     String^ connStr = L"datasource=192.168.0.68;port=3306;username=" + username->Text + L";password=" + password->Text + L";database=cashier";
                     MySqlConnection^ conn;
                     try {
                          conn= gcnew MySqlConnection(connStr);
                     }
                     catch (Exception^ e){
                         MessageBox::Show(e->Message);
                         return;
                     }

  3. While this code will work, it will open up your application to SQL injection attacks,
    Instead of writing

    MySqlCommand^ cmdDataBase = gcnew MySqlCommand("SELECT * FROM database WHERE user_name= '"+this->username_txt->Text+"' AND password= '"+this->password_txt->Text+"';", conDataBase);

    You should write something like

    MySqlCommand^ cmdDataBase = gcnew MySqlCommand("SELECT * FROM database WHERE user_name=@Name AND password=@Password;", conDataBase);

    and then add 2 new lines of code like so

    cmdDataBase->Parameters->Add("@Name", username_txt->Text);
    cmdDataBase->Parameters->Add("@Password", password_txt->Text);

    You can add this code in between

    conDataBase->Open();
    {ADD THE CODE HERE}
    myReader = cmdDataBase->ExecuteReader();

    This will stop inputs like [  anything' OR 'x'='x  ]  giving access to your program anyway.

  4. thank you! put i found an issue, if you have two accounts, bob with the password of bob and Joe with a password of Joe, you can type in bob and Joe and it works, it doesn't make sure the password matches the username ): can you help me?

Leave a Reply