Click here to Skip to main content
15,888,984 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: about listbox [modified] Pin
Naveen7-Jun-06 22:09
Naveen7-Jun-06 22:09 
GeneralRe: about listbox Pin
vasusree7-Jun-06 22:53
vasusree7-Jun-06 22:53 
QuestionWord File Pin
Sharath867-Jun-06 19:39
Sharath867-Jun-06 19:39 
AnswerRe: Word File Pin
NiceNaidu7-Jun-06 19:48
NiceNaidu7-Jun-06 19:48 
GeneralRe: Word File Pin
Steve Echols7-Jun-06 19:51
Steve Echols7-Jun-06 19:51 
GeneralRe: Word File Pin
Sharath867-Jun-06 20:11
Sharath867-Jun-06 20:11 
AnswerRe: Word File Pin
Hamid_RT7-Jun-06 20:02
Hamid_RT7-Jun-06 20:02 
QuestionLogin paswrd problem [modified] Pin
p_7-Jun-06 19:26
p_7-Jun-06 19:26 
when i enter usename and password it will give that incorrect usename and password plz try later option
even that username and password are in the mysql table users
plz tel me or send me any working code


i make a dialob box in mfc which contain two edit controls one for usename and other for password and a button for login
now i made a table users in mysql which contain user names and passwords
now i want when i click on login button the usename and passwrd conformation is made from mysql table and it then login else not
i use this code but ot not works for me plz tel me the code:::

void CPasswordDlg::OnLog()
{
int i, j, k;
MYSQL * myDB ;
MYSQL_RES * res,*res1;
MYSQL_ROW row,row1;
CString sStr, sPwd;

GetDlgItem(IDC_LOG)->EnableWindow(FALSE);
SetDlgItemText(IDC_STATIC, "Logging in. Please wait...");

if ( (myDB = mysql_init((MYSQL*) 0)) &&
mysql_real_connect( myDB, "localhost", "root", NULL, NULL, MYSQL_PORT, NULL, CLIENT_MULTI_STATEMENTS ) )

{
if ( mysql_select_db( myDB, "gourav") < 0 )
{
SetDlgItemText(IDC_STATIC, "Can't select the database !\nTry later.") ;
goto exit_here;
}
}
else
{
SetDlgItemText(IDC_STATIC, "Can't connect to the mysql server !\nPlease try later.") ;
goto exit_here;
}




GetDlgItemText(IDC_USER, sStr);
GetDlgItemText(IDC_PASS, sPwd);

sStr = "SELECT * FROM Users WHERE UserID=\'" + sStr + "\'";
if ( ! mysql_query( myDB, sStr) )
{
res = mysql_store_result( myDB ) ;
i = (int) mysql_num_rows( res );
if (i != 1)
{
SetDlgItemText(IDC_STATIC, "Incorrect User Name / Password. Please try again.");
mysql_free_result( res ) ;
goto exit_here;
}
if ( (row = mysql_fetch_row( res )) )
{
sStr.Empty();
j = mysql_num_fields( res ) ;
//for ( k = 0 ; k < j ; k++ )
// sStr += (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k]) ;

sPwd = (((row[3]==NULL)||(!strlen(row[3])))?"NULL":row[3]);
GetDlgItemText(IDC_PASS, sStr);
sStr = "SELECT PASSWORD(\'" + sStr + "\')";
if ( ! mysql_query( myDB, sStr) )
{
res1 = mysql_store_result( myDB ) ;
if ( (row1 = mysql_fetch_row( res1 )) )
{
sStr = (((row1[0]==NULL)||(!strlen(row1[0])))?"NULL":row1[0]);
if (sStr == sPwd)
{
SetDlgItemText(IDC_STATIC, "Login Successful.");
}
else
SetDlgItemText(IDC_STATIC, "Incorrect User Name / Password. Please try again.");
}
mysql_free_result( res1 ) ;
}
else
SetDlgItemText(IDC_STATIC, "Could not execute query01 on server.") ;
}
mysql_free_result( res ) ;
}
else
SetDlgItemText(IDC_STATIC, "Could not execute query on server.") ;


exit_here:
GetDlgItem(IDC_LOG)->EnableWindow(TRUE);
mysql_close( myDB );

}





hi

-- modified at 2:13 Thursday 8th June, 2006
QuestionRe: Login paswrd problem Pin
Hamid_RT7-Jun-06 19:35
Hamid_RT7-Jun-06 19:35 
AnswerRe: Login paswrd problem Pin
p_7-Jun-06 20:33
p_7-Jun-06 20:33 
GeneralRe: Login paswrd problem Pin
kakan7-Jun-06 20:45
professionalkakan7-Jun-06 20:45 
GeneralRe: Login paswrd problem Pin
p_7-Jun-06 21:04
p_7-Jun-06 21:04 
QuestionRe: Login paswrd problem Pin
Hamid_RT7-Jun-06 21:17
Hamid_RT7-Jun-06 21:17 
AnswerRe: Login paswrd problem Pin
p_7-Jun-06 21:25
p_7-Jun-06 21:25 
GeneralRe: Login paswrd problem Pin
kakan7-Jun-06 21:20
professionalkakan7-Jun-06 21:20 
GeneralRe: Login paswrd problem Pin
p_7-Jun-06 21:28
p_7-Jun-06 21:28 
QuestionBlocking in CSocket Pin
zahid_ash7-Jun-06 19:12
zahid_ash7-Jun-06 19:12 
AnswerRe: Blocking in CSocket Pin
Laxman Auti7-Jun-06 19:32
Laxman Auti7-Jun-06 19:32 
GeneralRe: Blocking in CSocket Pin
zahid_ash7-Jun-06 20:57
zahid_ash7-Jun-06 20:57 
GeneralRe: Blocking in CSocket Pin
Laxman Auti7-Jun-06 21:06
Laxman Auti7-Jun-06 21:06 
GeneralRe: Blocking in CSocket Pin
zahid_ash7-Jun-06 23:23
zahid_ash7-Jun-06 23:23 
GeneralRe: Blocking in CSocket Pin
Mila0258-Jun-06 6:19
Mila0258-Jun-06 6:19 
QuestionProblem with sipxtapi project Pin
Amit Agarrwal7-Jun-06 18:53
Amit Agarrwal7-Jun-06 18:53 
QuestionHow to get caption of a popup menu Pin
kflrei7-Jun-06 18:49
kflrei7-Jun-06 18:49 
AnswerRe: How to get caption of a popup menu Pin
Ganesh_T7-Jun-06 19:10
Ganesh_T7-Jun-06 19:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.