User Login using sqlite
Posted: Fri Mar 23, 2018 2:23 am
Hello, I'm just started using LiveCode few days ago and for today I'm stuck at making the user to login with the correct account details from the database. The database is created from sqlite by Livecode.
I got 2 fields , 1 for username and another 1 for password. I also got 1 button for user to log in.
name of username field= fieldforemail
name of password field = fieldforpw
name of button = loginbtn
name of table = account_details
table details = user_id integer primary key,email char(50), password char(50)
Basically i want the user to type in the correct username and password in the form then if the user type in the correct username and password which match the account_detail in the database then it allow them to go to the next page.
Can i know what code to be type in the button for the user to login???
PS: My database and table is created and work perfectly, As i'm able to insert and view the account_details data.
Below is my code for the card script.
---------------------------------------------------------------------------
## Use a script local variable to store the database id
local sDatabaseID
## Handlers to get and set the variable storing the database id
command setDatabaseID pDatabaseID
put pDatabaseID into sDatabaseID
end setDatabaseID
function getDatabaseID
return sDatabaseID
end getDatabaseID
command databaseConnect
local tDatabasePath, tDatabaseID
## The database must be in a writeable location
put specialFolderPath("documents") & "/runreaccount1.sqlite" into tDatabasePath
## Open a connection to the database
## If the database does not already exist it will be created
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID
## Store the database id as a custom property so other handlers can access it
setDatabaseID tDatabaseID
end databaseConnect
command databaseClose
revCloseDatbase sDatabaseID
end databaseClose
------------------------------------------------------------------------------------------------------
Any help is appreciated,thanks!
I got 2 fields , 1 for username and another 1 for password. I also got 1 button for user to log in.
name of username field= fieldforemail
name of password field = fieldforpw
name of button = loginbtn
name of table = account_details
table details = user_id integer primary key,email char(50), password char(50)
Basically i want the user to type in the correct username and password in the form then if the user type in the correct username and password which match the account_detail in the database then it allow them to go to the next page.
Can i know what code to be type in the button for the user to login???
PS: My database and table is created and work perfectly, As i'm able to insert and view the account_details data.
Below is my code for the card script.
---------------------------------------------------------------------------
## Use a script local variable to store the database id
local sDatabaseID
## Handlers to get and set the variable storing the database id
command setDatabaseID pDatabaseID
put pDatabaseID into sDatabaseID
end setDatabaseID
function getDatabaseID
return sDatabaseID
end getDatabaseID
command databaseConnect
local tDatabasePath, tDatabaseID
## The database must be in a writeable location
put specialFolderPath("documents") & "/runreaccount1.sqlite" into tDatabasePath
## Open a connection to the database
## If the database does not already exist it will be created
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID
## Store the database id as a custom property so other handlers can access it
setDatabaseID tDatabaseID
end databaseConnect
command databaseClose
revCloseDatbase sDatabaseID
end databaseClose
------------------------------------------------------------------------------------------------------
Any help is appreciated,thanks!
