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!
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.
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
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
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).