Simple Login System
In this lesson we will teach you how to create a simple login system that can be used on your stack. Although this is a simple method of implementing such a feature, it can be built upon to create more advanced systems.
1) Create a new stack
2) Name the stack "Login Test"
3) Name this first card "Login"
1) Add label field with "Access Granted"
2) Add button with following script
on mouseUp go to the first card end mouseUp
1) Navigate to log in card
2) Create two input fields. One called username and one called password
3) Create two label fields. One with its contents set to "Username" and the other "Password"
4) Create a button and set its label to "Login"
Place the following in your card script
local sUsername, sPassword on openCard put "johnsmith" into sUsername put "pa55word" into sPassword end openCard on loginCheck if field "username" is sUsername and field "password" is sPassword then go to card "accessed" else answer "Details Incorrect. Please try again!" end if end loginCheck
The above script puts a defined username and password into a variable and then the loginCheck handler checks if the contents of the username and password fields matches these values.
If a match is successful then you progress to the next card. However, if details are in-correct then an answer dialog is shown.