Hello,
I've managed to get a User Login working for my website. The users details are kept on a separate .txt file in the same directory, called members.txt.
Here's how the text file looks:
The login button is coded as follows:
The login works fine. See the numbers at the end of each line in the members.txt file? That's the user permission level. I've got a button (only accessed once logged in) that requires the user's level to be at least 5. As you can see, I've got two users so far, one is level 4, one is level 6. I've done this so I can test this section out.Code:on (release, keyPress "<Enter>") {
user=user;
for (var ndx = 0; ndx<totalMembers; ++ndx) {
if (user == memberArray[ndx][0]) {
if (pass == memberArray[ndx][1]) {
gotoAndStop("Website", 1);
success = true;
userlevel = memberArray[ndx][3];
youremail=memberArray[ndx][2];
password=memberArray[ndx][1];
Submit = "Yes";
}
}
if (false == success) {
gotoAndStop(4);
error = "Login details incorrect. Please try again.";
}
}
}
My problem is that both users can still access the level 5 section. Here's the code on the button:
Also, from the traces in that code, I get the following results:Code:on (release) {
_root.userlevel = memberArray[ndx][3];
trace(_root.userlevel);
// what is the result ?
trace(typeof _root.userlevel);
// what is the result ?
trace(ndx);
// is this index number viable ?
trace(memberArray[ndx][3]);
// undefined ??
trace(_root.memberArray[ndx][3]);
// what result here with _root.prefix ??
if (_root.userlevel>="5") {
pages.gotoAndStop("special");
}
// end if
}
Can anyone see what I've done wrong here? Any help is greatly appreciated.Code:undefined
undefined
2
undefined
undefined
Thanks.
