Based on this code, how would I make a register button

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Based on this code, how would I make a register button

Post by dunbarx » Thu Sep 08, 2022 2:30 pm

One cannot use global variables to store anything that needs to survive sessions. Globals do not; they must be populated each and every time. Such data should be either in a field, a custom property or an external file. If you have concerns about security, though it sounds like you do not, let us know.

Craig

Klaus
Posts: 13823
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Based on this code, how would I make a register button

Post by Klaus » Thu Sep 08, 2022 2:31 pm

Code: Select all

global gChosenName,gChosenPassword

## Better use another name for this handler, since it is not (yet) the LOGIN handler
## Of course you can and should change the handler and variable names to fit your needs.
on SetUserNamePWD
   ask "What username do you want?"
   put it into gChosenName
   ask "What password do you want"
   put it into gChosenPassword
end SetUserNamePWD
Then you can later use these globals to compare.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Based on this code, how would I make a register button

Post by dunbarx » Thu Sep 08, 2022 2:33 pm

Klaus.

Why are you still set on using globals? These die every time you quit LC.

Craig

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Based on this code, how would I make a register button

Post by stam » Thu Sep 08, 2022 2:37 pm

As Richard mentioned earlier, it's good practice not to store the password per se, but a 1-way hash of it (so that the password cannot be divined from stored data). When the user enters a password it should be hashed in the same way to compare with the stored hash if that makes sense...

look at messageDigest in the dictionary...

S.

Klaus
Posts: 13823
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Based on this code, how would I make a register button

Post by Klaus » Thu Sep 08, 2022 2:41 pm

dunbarx wrote:
Thu Sep 08, 2022 2:33 pm
Klaus.
Why are you still set on using globals?
I didn't expect the spanish inquisition! :-D
dunbarx wrote:
Thu Sep 08, 2022 2:33 pm
These die every time you quit LC.
Why didn't anybody tell me? :-D

Yes, sorry, Craig, pure lazyness, of course one needs to save these globals somewhere before quitting LC.

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Based on this code, how would I make a register button

Post by stam » Thu Sep 08, 2022 2:44 pm

dunbarx wrote:
Thu Sep 08, 2022 2:33 pm
Why are you still set on using globals? These die every time you quit LC.
It may a useful intermediary step, if for example there is a subsequent handler that stores the password. And of course the OP is just using this for test purposes

However in this context i would probably avoid using globals anyway, just a script local (ie replace the the 'global' keyword with 'local' - it then becomes a variable that is 'global' for the script only and available to all handlers below it).

S.

Curiousbystander
Posts: 20
Joined: Wed Sep 07, 2022 4:26 pm

Re: Based on this code, how would I make a register button

Post by Curiousbystander » Thu Sep 08, 2022 2:54 pm

Thank you all for educating me.

It's working now, thank you again.

Klaus
Posts: 13823
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Based on this code, how would I make a register button

Post by Klaus » Thu Sep 08, 2022 3:04 pm

I highly recommend these stacks to get a grip of the basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Based on this code, how would I make a register button

Post by dunbarx » Thu Sep 08, 2022 3:37 pm

@Klaus

Ha. Nobody does. :D

@CuriousBystander. It is important to understand these points, that is, security and also how to store data in your stacks. For the data, no variable of any kind will survive a new session. Your options are the three I mentioned earlier. I think you should practice using custom properties. They are wonderful and can store any kind of data.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”