C++ MFC Dialog Login Error
-
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);
}
-
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);
}
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
-
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);
}
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
-
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
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
-
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
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