| | |
LOGIN
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2009
Posts: 16
Reputation:
Solved Threads: 0
please i was wondering if anyone could help me with my code, i feel its kinda too long and a good program should be as brief as possible... please would be very grateful. appreciated, cheers..
C++ Syntax (Toggle Plain Text)
int _tmain(int argc, _TCHAR* argv[]) { string Username; string Password; int terminator = 0, terminate = 0; char encrypt; while (terminate < 2) { cout << "Enter Username: "; getline(std::cin, Username); if (Username == "Raymond") { terminate = terminate + 3; while (terminator < 2) { cout << "\nEnter Password: "; encrypt = _getch(); while(encrypt != 13) { Password.push_back(encrypt); cout << '*'; encrypt = _getch(); } if (Password == "123456") { cout <<"\n\n\t\t******************************"; cout << "\n\t\t* *"; cout << "\n\t\t* *"; cout << "\n\t\t* Welcome Raymond * "; cout << "\n\t\t* *"; cout <<"\n\t\t******************************"<< endl<<endl ; terminator = terminator + 3; } else { cout << "\nInvalid password. Please enter valid password." << std::endl; cout << "\a\n"; terminator = terminator + 1; } } } else { cout << "Invalid username. Please enter valid username." << std::endl; cout << "\a\n"; terminate = terminate + 1; } } return 0; }
Last edited by Narue; Apr 10th, 2009 at 11:42 am. Reason: fixed code tags
Why are you hard coding the username and password in the code, if you want to improve your login system (make it more universal) you could make an account database where the username and password are stored in ...
Edit:: You could also use a
Edit:: It's also a bad security practice when you're notifying the user when a username doesn't exist, it would be better if you ask the user to enter a username and a password, and when one of these is wrong you simply notify the user with "Wrong username or password" ...
Edit:: You could also use a
bool called 'terminate', and you let your while run like this while(!terminate) ...Edit:: It's also a bad security practice when you're notifying the user when a username doesn't exist, it would be better if you ask the user to enter a username and a password, and when one of these is wrong you simply notify the user with "Wrong username or password" ...
Last edited by tux4life; Apr 10th, 2009 at 12:01 pm.
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
![]() |
Similar Threads
- Windows XP slow login (Windows NT / 2000 / XP)
- network login problem (Windows NT / 2000 / XP)
- can't get past xp login (Windows NT / 2000 / XP)
- XP anf Novell Client Dual Login (Novell)
- Cannot Login to Mac (OS X)
- login screen config (Window and Desktop Managers)
Other Threads in the C++ Forum
- Previous Thread: get rid of the punctuations function
- Next Thread: Databasing problem
Views: 271 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct temperature template templates text tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






