Well, if i've understood you right, you want to check all combinations of login and password, i.e. n*m variants, where n is number of logins and m is number of passwords.
If so, you're doing it in a wrong way, you should:
@
else if (!username.isEmpty() && !passcode.isEmpty())
{
for (int i = 0; i < sUsername.count(); j++)
for (j = 0; j < sPasscode.count(); j++)
{
if ((username == sUsername[i]) && (passcode == sPasscode[j]))
{
// You are successfully logged on to the program
ui->nameEdit->clear();
ui->codeEdit->clear();
QMessageBox::information(this, tr("Login Screen"), tr("You have successfully logged on to this program!"));
}
else
{
QMessageBox::information(this, tr("Login Screen"), tr("Sorry but that was an invalid username or passcode.\nTry again..."));
}
}
}
@
But I don't understand the meaning of this procedure: if you want to authenticate user, then you should check that he entered correct password for some correct login. Something like:
@
else if (!username.isEmpty() && !passcode.isEmpty()) {
if (users.count(username)) {
if (passcodes[username] == passcode) {
QMessageBox::information(this, tr("Login Screen"), tr("You have successfully logged on to this program!"));
}
else {
QMessageBox::information(this, tr("Login Screen"), tr("Sorry but that was an invalid passcode.\nTry again..."));
}
}
else {
QMessageBox::information(this, tr("Login Screen"), tr("Sorry but that was an invalid username.\nTry again..."));
}
}
@