Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
Jamie37
- Posts: 53
- Joined: Sat Dec 19, 2015 1:45 pm
Post
by Jamie37 » Tue Feb 02, 2016 9:00 pm
Hello,
I followed the simple login system tutorial on the livecode website and it went well. I currently have this code
Code: Select all
global sUsername, sPassword
on openCard
get sUsername
get sPassword
put sUsername into sUsername1
put sPassword into sPassword1
end openCard
on loginCheck
if field "username" is sUsername and field "password" is sPassword then
go to card "Access"
else
answer "Details incorrect. Please try again!"
end if
end loginCheck
on openCard
focus on fld "username"
end openCard
This basically checks for the username and password in a custom variable created through a separate registration page. What I want to do is ask the user whether or not they want to remember their details. I can get the dialog box to come up asking them the question, however I can not get another if statement to work under the current one which will allow me to get the result of the question and continue with the current code. Its hard to explain but hopefully somebody gets it and can help me.
Thanks
Jamie
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Tue Feb 02, 2016 11:14 pm
Hi.
Probably need to see your code to help you.
I have never gone through a tutorial. Is the following code snippet really there?
Do you see why I ask?
Craig Newman
-
A1Qicks
- Posts: 79
- Joined: Sat Dec 26, 2015 10:47 am
Post
by A1Qicks » Wed Feb 03, 2016 9:49 am
dunbarx wrote:Hi.
Probably need to see your code to help you.
I have never gone through a tutorial. Is the following code snippet really there?
Do you see why I ask?
Craig Newman
It's just a handholding thing. The code has to be reassured that the variables are filled, otherwise it gets nervous

-
Jamie37
- Posts: 53
- Joined: Sat Dec 19, 2015 1:45 pm
Post
by Jamie37 » Wed Feb 03, 2016 10:51 am
Hi,
Sorry I probably should have uploaded this code as well. This code below is the button which puts the fields into the variables to be read.
Code: Select all
global sUsername, sPassword
on RegCheck
put field "Regusername" into sUsername
put field "Regpassword" into sPassword
end RegCheck
on openCard
focus on fld "Regusername"
end openCard
on closeCard
put empty into field "Regpassword"
put empty into field "Regusername"
end closeCard
-
Klaus
- Posts: 14199
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Wed Feb 03, 2016 3:13 pm
Hi Jamie,
"get XYZ" will only put XYZ into the variable IT, so this does not make sense here and that is why Craig was asking
Not sure I understand your problem, but maybe this is what you are looking for?
Code: Select all
on loginCheck
## BOTH have to be correct!
if field "username" <> sUsername OR field "password" <> sPassword then
answer "Details incorrect. Please try again!"
exit logincheck
end if
answer "Do you want me to remember your log in data?" with "Yes" or "No" or "Maybe?"
if it = Yes" then
## store username and password or do wahtever you want to do in that case...
end if
## Finally:
go to card "Access"
end loginCheck
Best
Klaus
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Wed Feb 03, 2016 9:17 pm
As a side note, it's often considered useful to never store the password itself, but instead store a hashed version of the password, such as you can get using LC's sha1Digest function. This way if the stored password is ever compromised, the attacker still won't have the password itself (even more useful when we consider how frequently people use a single password for multiple services).
e.g.:
Code: Select all
if field "username" <> sUsername OR field "password" <> sha1Direct(sPassword) then