Login Script Using MySQL Database
Posted: Sat Oct 03, 2015 5:19 pm
Hi,
I try to create a login page for my simple application. I have a MySQL database on a hosting and connected to my application once the stack is opened.
I have table name "staff" on that database consist of staffId and Password.
I have created a text field "sID" and "password" on the interface, and login button.
I am not sure the correct code to write for calling and compare the data from the table.
I used the following codes but it is not working:
Please help, or point me to guide on creating login using MySQL database.
I try to create a login page for my simple application. I have a MySQL database on a hosting and connected to my application once the stack is opened.
I have table name "staff" on that database consist of staffId and Password.
I have created a text field "sID" and "password" on the interface, and login button.
I am not sure the correct code to write for calling and compare the data from the table.
I used the following codes but it is not working:
Code: Select all
on mouseUp
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- construct the SQL (this selects all the data from the specified table)
put "staff" into tTableName -- set this to the name of a table in your database
put "SELECT * FROM " & tTableName into tSQL
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
-- check the result and display the data or an error message
if field "sID" = item 1 of tTableName and field "sIC" = item 3 of tTableName then
go to card "gUser"
else
answer error "There was a problem querying the database:" & cr & tData
end if
end mouseUp