Sponsored Content
Full Discussion: C++ Login System help.
Top Forums Programming C++ Login System help. Post 302488129 by andylbh on Saturday 15th of January 2011 09:34:26 AM
Old 01-15-2011
C++ Login System help.

I'm new to C++.
I have a text file named idpw.txt which is storing id and password
e.g
admin password
account1 abc
john hello

Here's my code so far:

Code:
bool login()
{
 string user[10],password[10], user1, password1;
 ifstream myfile("idpw.txt");
 
 cout << "Please enter your username" << endl;
 cin >> user1;
 cout << "Please enter your password" << endl;
 cin >> password1;
 
 int i=0;
 int j=0;
 while (!myfile.eof())
 {
  myfile >> user[i] >> password[i];
  i++;
 }
 myfile.close();
 
 for (j=0; j<i; j++)
 {
  if (user1 == user[j] && password1 == password[j])
  {
   cout << "Successfully Login" << endl;
   return true;
  }
 }
}

I can login successfully, but here's the problem.
I want to do it in a sense that:
1) When username is correct, but password is wrong, error message will be : "Wrong Password"
2) When username is not in the list, error message will be : "No such user exist"
3) If a user typed in wrong password for 3 times, account will be locked.

Am I doing the login function right? The for loop for int j seems really wrong.
Is there a way to do this?

Thanks alot in advance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

past login still exist in the system

hi, i noticed that there are still past logins which have not been terminated. how should i removed them? i am on aix. (9 Replies)
Discussion started by: yls177
9 Replies

2. Solaris

How to check the last login user were doing in the system

Hi, I'm new to solaris/ Unix and would like to know how to check in the system what was the last login user were doing. Is there any way to check this? Thanks in advanced. (1 Reply)
Discussion started by: raziayub
1 Replies

3. Cybersecurity

Disablin login for system accounts

Hy everyone! I'm trying to lock out system accounts on my Tru64 UNIX machines. Wherever I look, it says only to put Nologin or *Nologin in password field of desired account in /etc/passwd. But it doesn't work. I still can su to that accounts. There are some accounts that already have Nologin... (1 Reply)
Discussion started by: veccinho
1 Replies

4. HP-UX

Prompted for System Password during login

Hello, I'm new to HP-UX. I have a system running B.11.23 on ia64. The system gets its user passwords via active directory. Everytime a new account is added to AD a script pushes out the account info to all the systems and this system is updated too. However, on this machine, users are unable to... (2 Replies)
Discussion started by: BFLO
2 Replies

5. Solaris

how do you login as sms-svc on a system controller

hi, i have got a SUN F15K DOMAIN TAKING HARDWARE CONFIGURATION DUMP. DUMP FILE: -D/VA message i wnat to logon as sms-svc on to the controller to check what's happening can you please guide me how do i login as sms-svc on the controller and check thank you (1 Reply)
Discussion started by: vinix
1 Replies

6. Shell Programming and Scripting

How can i use system users in perl for login page

Hi, I want to code a script with perl. For this, I need some knowledge. How can i use system user name(with group) and password in my login page? I will be happy if you can help me (2 Replies)
Discussion started by: tahsinaltay
2 Replies

7. UNIX for Advanced & Expert Users

system not login

Hi, I was add my shell script in /etc/rc.d/rc.local file Eg. sh /root/KernelModule.sh my KernelModule.sh contain insmod xxxxx.ko insmod yyyy.ko I have insmod 22 kernelmodule in this script , all the modules are my own driver modules. now problem is my system is booting but... (2 Replies)
Discussion started by: rajamohan
2 Replies

8. UNIX for Dummies Questions & Answers

System list of all UNIX login accounts

What is the command to list all UNIX system login accounts? What is the command to list all system password parameters for UNIX(minimum length, complexity,age, invalid lockout attempts, expiration date , user inactivity lockout) (1 Reply)
Discussion started by: ma466
1 Replies

9. AIX

Hanging in the system after login !

Guy's I have AIX 6.1 has some slowness when I login to the system .. When I login by user screen hangs for some time 20 seconds then it's give me the command prompt .. ! system is fine is working fine only this issue I faced can you please help me in this .. what's the expected reason... (2 Replies)
Discussion started by: ITHelper
2 Replies

10. Solaris

Finding system uptime without login

Hi, Am writing a script where I want to find uptime of certain servers. Is there any command where we can find uptime without login to the server, since the server list is big logging to the server will time consuming. Thanks in advance (7 Replies)
Discussion started by: rogerben
7 Replies
LOGIN(1)						      General Commands Manual							  LOGIN(1)

NAME
login - sign on SYNOPSIS
login [ username ] DESCRIPTION
The login command is used when a user initially signs on, or it may be used at any time to change from one user to another. The latter case is the one summarized above and described here. See `How to Get Started' for how to dial up initially. If login is invoked without an argument, it asks for a user name, and, if appropriate, a password. Echoing is turned off (if possible) during the typing of the password, so it will not appear on the written record of the session. After a successful login, accounting files are updated and the user is informed of the existence of .mail and message-of-the-day files. Login initializes the user and group IDs and the working directory, then executes a command interpreter (usually sh(1)) according to speci- fications found in a password file. Argument 0 of the command interpreter is `-sh. Login is recognized by sh(1) and executed directly (without forking). FILES
/etc/utmp accounting /usr/adm/wtmp accounting /usr/mail/* mail /etc/motd message-of-the-day /etc/passwd password file SEE ALSO
init(8), newgrp(1), getty(8), mail(1), passwd(1), passwd(5) DIAGNOSTICS
`Login incorrect,' if the name or the password is bad. `No Shell', `cannot open password file', `no directory': consult a programming counselor. LOGIN(1)
All times are GMT -4. The time now is 09:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy