SOLVED - login with username and password
Posted: Tue Jul 26, 2011 2:24 pm
I wrote the following code to login to the database. There is a table called UserValidation which holds the username and password info. I want this script to look up the user and allow access if they are in the system.
Right now, it always returns a "wrong username and password" even though I am entering the correct one.
=====================================
on mouseUp
--Create a global variable for the db
global dbID
-- put the Ip address of the MySQL Server
--put the name of your DB
-- then your login
--then your password
--this connects to the database
put revOpenDatabase("MySQL","www.website.com","client_database","username","password") into dbID
if dbID is not a number then
answer warning "Error "&dbID
exit to top
else
--answer "connection successful"
end if
--load username and password
put "SELECT UserName,Password FROM UserValidation" into theUN
put revDataFromQuery(,,dbID,theUN) into theUNData
if theUNData contains "revdberr" then
answer warning "There is an error "&theUNData
exit to top
end if
if theUNData = the text of field "fldUserName" and theUNData = the text of field "fldPassword1" then
go to card ReturnRegistration
else
answer "Incorrect username or password. Please try again."
exit to top
end if
end mouseUp
on mouseenter
set the text of field "lblHints" to "CLICK THIS BUTTON to login to the database"
end mouseenter
on mouseleave
set the text of field "lblHints" to empty
end mouseleave
=============================================
If anyone could help me with the syntax, it would be most appreciated.
Mike
Right now, it always returns a "wrong username and password" even though I am entering the correct one.
=====================================
on mouseUp
--Create a global variable for the db
global dbID
-- put the Ip address of the MySQL Server
--put the name of your DB
-- then your login
--then your password
--this connects to the database
put revOpenDatabase("MySQL","www.website.com","client_database","username","password") into dbID
if dbID is not a number then
answer warning "Error "&dbID
exit to top
else
--answer "connection successful"
end if
--load username and password
put "SELECT UserName,Password FROM UserValidation" into theUN
put revDataFromQuery(,,dbID,theUN) into theUNData
if theUNData contains "revdberr" then
answer warning "There is an error "&theUNData
exit to top
end if
if theUNData = the text of field "fldUserName" and theUNData = the text of field "fldPassword1" then
go to card ReturnRegistration
else
answer "Incorrect username or password. Please try again."
exit to top
end if
end mouseUp
on mouseenter
set the text of field "lblHints" to "CLICK THIS BUTTON to login to the database"
end mouseenter
on mouseleave
set the text of field "lblHints" to empty
end mouseleave
=============================================
If anyone could help me with the syntax, it would be most appreciated.
Mike