Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Site Bugs / Suggestions
  4. C++ MFC Dialog Login Error

C++ MFC Dialog Login Error

Scheduled Pinned Locked Moved Site Bugs / Suggestions
c++databasehelpmysqlquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WinterC
    wrote on last edited by
    #1

    Here is my code for my login dialog application. there is this error whereby any username and password will allow user to login. i link it with mysql database but its not checking for the user and just login with unexisting users. please help me solve this i don know where i go wrong or lack of anything else? thank you!

    void CPeopleCounterDlg::OnBnClickedbtnlogin()
    {
    UpdateData();
    bool ValidLogin = false;

    if( m\_Username == "" )
    {
        AfxMessageBox("You must provide a username to Login.");
        m\_EditUsername.SetFocus();
    
        return;
    }
    if( m\_Password == "" )
    {
        AfxMessageBox("Please enter your password.");
        m\_EditPassword.SetFocus();
        return;
    }
            //SQL查询语句
        if(mysql\_query( ssock,"SELECT \* FROM user WHERE Username == \\"m\_Username\\" AND Password == \\"m\_Password\\" "))
        {
            ValidLogin = true;
            CPplCMain  m\_pplc;
            m\_pplc.DoModal();
            this->ShowWindow(SW\_HIDE);
            this->ShowWindow(SW\_SHOW);
        }
        if(ValidLogin = false){
            MessageBox("Invalid login!");
        }
        if( !(res = mysql\_store\_result(ssock)) )
    {
        MessageBox("Disconnected!", mysql\_error(ssock));
    }
    UpdateData(FALSE);
    mysql\_close(ssock);
    

    }

    S N 2 Replies Last reply
    0
    • W WinterC

      Here is my code for my login dialog application. there is this error whereby any username and password will allow user to login. i link it with mysql database but its not checking for the user and just login with unexisting users. please help me solve this i don know where i go wrong or lack of anything else? thank you!

      void CPeopleCounterDlg::OnBnClickedbtnlogin()
      {
      UpdateData();
      bool ValidLogin = false;

      if( m\_Username == "" )
      {
          AfxMessageBox("You must provide a username to Login.");
          m\_EditUsername.SetFocus();
      
          return;
      }
      if( m\_Password == "" )
      {
          AfxMessageBox("Please enter your password.");
          m\_EditPassword.SetFocus();
          return;
      }
              //SQL查询语句
          if(mysql\_query( ssock,"SELECT \* FROM user WHERE Username == \\"m\_Username\\" AND Password == \\"m\_Password\\" "))
          {
              ValidLogin = true;
              CPplCMain  m\_pplc;
              m\_pplc.DoModal();
              this->ShowWindow(SW\_HIDE);
              this->ShowWindow(SW\_SHOW);
          }
          if(ValidLogin = false){
              MessageBox("Invalid login!");
          }
          if( !(res = mysql\_store\_result(ssock)) )
      {
          MessageBox("Disconnected!", mysql\_error(ssock));
      }
      UpdateData(FALSE);
      mysql\_close(ssock);
      

      }

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      this forum is for reporting bugs or suggest to / with the Codeproject web site. I would post your question here C-C++-MFC forum[^]

      Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

      1 Reply Last reply
      0
      • W WinterC

        Here is my code for my login dialog application. there is this error whereby any username and password will allow user to login. i link it with mysql database but its not checking for the user and just login with unexisting users. please help me solve this i don know where i go wrong or lack of anything else? thank you!

        void CPeopleCounterDlg::OnBnClickedbtnlogin()
        {
        UpdateData();
        bool ValidLogin = false;

        if( m\_Username == "" )
        {
            AfxMessageBox("You must provide a username to Login.");
            m\_EditUsername.SetFocus();
        
            return;
        }
        if( m\_Password == "" )
        {
            AfxMessageBox("Please enter your password.");
            m\_EditPassword.SetFocus();
            return;
        }
                //SQL查询语句
            if(mysql\_query( ssock,"SELECT \* FROM user WHERE Username == \\"m\_Username\\" AND Password == \\"m\_Password\\" "))
            {
                ValidLogin = true;
                CPplCMain  m\_pplc;
                m\_pplc.DoModal();
                this->ShowWindow(SW\_HIDE);
                this->ShowWindow(SW\_SHOW);
            }
            if(ValidLogin = false){
                MessageBox("Invalid login!");
            }
            if( !(res = mysql\_store\_result(ssock)) )
        {
            MessageBox("Disconnected!", mysql\_error(ssock));
        }
        UpdateData(FALSE);
        mysql\_close(ssock);
        

        }

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        When Chris was younger and used real programming tools, he may have been able to help you. Today the most advanced coding he involves himself in would probably be manually closing an HTML tag. :-D [/***ducks***]

        Regards, Nish


        Blog: voidnish.wordpress.com

        C 1 Reply Last reply
        0
        • N Nish Nishant

          When Chris was younger and used real programming tools, he may have been able to help you. Today the most advanced coding he involves himself in would probably be manually closing an HTML tag. :-D [/***ducks***]

          Regards, Nish


          Blog: voidnish.wordpress.com

          C Offline
          C Offline
          Chris Maunder
          wrote on last edited by
          #4

          Closing HTML tags is what those uppity youngin's do. Waste of time! Garr - when I was a lad... (So do I use my big shiny Nuke This Thread button or do I leave this to allow the mocking to continue? Decisions, decisions...)

          cheers Chris Maunder

          T 1 Reply Last reply
          0
          • C Chris Maunder

            Closing HTML tags is what those uppity youngin's do. Waste of time! Garr - when I was a lad... (So do I use my big shiny Nuke This Thread button or do I leave this to allow the mocking to continue? Decisions, decisions...)

            cheers Chris Maunder

            T Offline
            T Offline
            Thanks7872
            wrote on last edited by
            #5

            Chris Maunder wrote:

            do I leave this to allow the mocking to continue?

            No.

            "When you don't know what you're doing it's best to do it quickly"- SoMad

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups