code to disable
-
i am sorry i an again disturbing u but i have a problem in loging in dialog box ihav dialog cbox which has tow edit boxes one for username and one for password so i want that when i enter username and password the it conform those from mysql table named user and when i enter admin type ysrname and passward it open one form and wheni enter pm username and password it open second dialog box note : mysql database may contain two tables one for users and one for authentication Please mail me
If you are making a database application, you should be able to read from the database and check the type of the user -- simple user or administrator. For instance, the "users" data table may contain a column which describes this type, for instance 0 for simple users or 1 for administrators. After you read the type from the database, you can do something like this:
int type = ... // the user’s type from database switch(type) { case 0: // regular user { CMyDialogForSimpleUsers dlg; dlg.DoModal(); } break; case 1: // administrator { CMyDialogForAdministrators dlg; dlg.DoModal(); } break; }
If you have troubles with databases using C++, I think you can post a separate question to the forum.
-
If you are making a database application, you should be able to read from the database and check the type of the user -- simple user or administrator. For instance, the "users" data table may contain a column which describes this type, for instance 0 for simple users or 1 for administrators. After you read the type from the database, you can do something like this:
int type = ... // the user’s type from database switch(type) { case 0: // regular user { CMyDialogForSimpleUsers dlg; dlg.DoModal(); } break; case 1: // administrator { CMyDialogForAdministrators dlg; dlg.DoModal(); } break; }
If you have troubles with databases using C++, I think you can post a separate question to the forum.
can u tel me how i make table in mysql for 0 and 1 type as u told me i simply create a table which contain username and password but as u told plz tel me abt how i create table for 0 user and 1 for adm Please mail me
-
can u tel me how i make table in mysql for 0 and 1 type as u told me i simply create a table which contain username and password but as u told plz tel me abt how i create table for 0 user and 1 for adm Please mail me
In the same manner as you created your users table containing two columns, you can create a table containing three columns. Just add one more column named "type" and having an integer type. If you use some database tools, like MySQL Query Browser, it is easy to add a new column to an existing table.
-
In the same manner as you created your users table containing two columns, you can create a table containing three columns. Just add one more column named "type" and having an integer type. If you use some database tools, like MySQL Query Browser, it is easy to add a new column to an existing table.
i am sorry for delay i try this code but as value fetched from mysql stored in row which is mysql variable and switch case does not work with this plz tel me . groupid is values 0 and 1 which store in mysql table. if (!mysql_query(myDB,"select groupid from users")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } //int type = ... // the user's type from database switch(row) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); } Please mail me
-
i am sorry for delay i try this code but as value fetched from mysql stored in row which is mysql variable and switch case does not work with this plz tel me . groupid is values 0 and 1 which store in mysql table. if (!mysql_query(myDB,"select groupid from users")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } //int type = ... // the user's type from database switch(row) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); } Please mail me
I am not an expert in databases, but I think your MySQL statement for determining groupid for a user by username should look like this:
"SELECT groupid from users **WHERE username='_the-user-name_'**"
.MYSQL_ROW
contains string, so I think yourswitch
must look like this:switch(**atoi(row[0])**)
. -
I am not an expert in databases, but I think your MySQL statement for determining groupid for a user by username should look like this:
"SELECT groupid from users **WHERE username='_the-user-name_'**"
.MYSQL_ROW
contains string, so I think yourswitch
must look like this:switch(**atoi(row[0])**)
.plz sir i distyurb u again but it gives no error but it does not go to second dialog box plz send me code for this if (!mysql_query(myDB,"SELECT groupid from users WHERE userid= \'" + user + "\' and \'" + pass + "\'")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } switch(atoi(row[0])) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); Please mail me
-
plz sir i distyurb u again but it gives no error but it does not go to second dialog box plz send me code for this if (!mysql_query(myDB,"SELECT groupid from users WHERE userid= \'" + user + "\' and \'" + pass + "\'")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } switch(atoi(row[0])) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); Please mail me
-
Try to put a breakpoint at
switch
, or useMessageBox
, in order to see which value containsrow[0]
. If it contains an unexpectedNULL
or a non-numeric string, thenatoi
returns0
.sir u geneous thanks but sir iwill not display second dialog box as second dialog box has class named CAdmin and first dialog box has class CAfterone case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAdmin dlg; dlg.DoModal(); } break; } Please mail me
-
sir u geneous thanks but sir iwill not display second dialog box as second dialog box has class named CAdmin and first dialog box has class CAfterone case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAdmin dlg; dlg.DoModal(); } break; } Please mail me
thanks a lot sir this works very well u r absolutly geneious Please mail me
-
plz tel me how can i check (mDisableSomeControls ) for updaet menu command how i write if(............) { GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE); } wat i write in if statement Please mail me
Please read this article[^] on why you do not want to use GetDlgItem and how you can avoid it while makeing your code mor readble. The author Joseph M. Newcomer is a old regular here on codeproject. His Page is full of great tips.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.