Login with GUI Matlab
Mostra commenti meno recenti
Hi, i alrdy success connecting my matlab with ms Access.. The problem is i doesnt know how to query. I have 2 edit text which to ask user to input username n password, after click login the system will refer to my databse. If wrong username n password the messagebox will popout and say fail.. any1 good at query the database can share
1 Commento
Muhamad Ikhwan
il 28 Feb 2017
Modificato: Geoff Hayes
il 1 Mar 2017
Risposte (1)
Geoff Hayes
il 1 Mar 2017
Muhammad - why are you comparing a with b
l=strcmp(a,b);
if l==1
% etc.
end
Aren't these the username and password and so should be different?
If curs.Data is a cell array (?) of usernames and passwords from the database, then I suspect that you would need to do something like
usernamePwdData = curs.Data;
guiUsername = get(handles.edit1,'String'); % I'm guessing edit1 is for username
guiPassword = get(handles.edit2,'String'); % I'm guessing edit2 is for password
validUser = false;
for k=1:length(usernamePwdData)
username = usernamePwdData{k,1};
password = usernamePwdData{k,2};
if strcmp(username,guiUsername) && strcmp(password,guiPassword)
validUser = true;
break;
end
end
if validUser
AdminManagement()
UserManagement()
else
msgbox('wrong pwd');
end
I'm also assuming that curs.Data is a cell array of N rows and 2 columns. If different, you would need to adjust the above code.
Categorie
Scopri di più su Workspace Variables and MAT Files in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!