SOLVED - Trying to create a simple hard coded admin login
Posted: Fri Jul 22, 2011 4:39 am
I am having a difficult time creating a admin login. It's a simple page with a username label and field, password label and field and a submit button. Two cards exist for this - one is called AdminLogin and the other is just called Admin.
Here is the code for all of it:
field named fldUserName (has no code)
field named fldPassword1: (code written by someone else to create a proper password entry box)
=================================================
on mouseenter
set the text of field "lblHints" to "Enter your password - this field is mandatory!"
end mouseenter
on mouseleave
set the text of field "lblHints" to empty
end mouseleave
on rawKeydown pKey
local tChunk,tPassword
-----
if pKey = 65288 then -- delete key
put word 1 to 4 of the selectedChunk into tChunk
put the uPassword of me into tPassword
if word 2 of tChunk > word 4 of tChunk then
put word 4 of tChunk into word 2 to 4 of tChunk
end if
do "put empty into" && tChunk && "of tPassword"
set the uPassword of me to tPassword
pass rawKeydown
else pass rawKeydown
end rawKeydown
------------------------------------
on keyDown pKey
local tChunk,tPassword
-----
if the selectedChunk = empty then pass keyDown
put word 1 to 4 of the selectedChunk into tChunk
put the uPassword of me into tPassword
put numToChar(42) into the selectedChunk -- numToChar(42): "*"
if chartonum(pKey) = 34 then -- replace any quote by "~"
do "put numToChar(126) into" && tChunk && "of tPassword"
else do "put" && quote & pKey & quote && "into" && tChunk && "of tPassword"
set the uPassword of me to tPassword
end keyDown
------------------------------------
on enterInfield
Validate --
end enterInfield
------------------------------------
on returnInfield
Validate --
end returnInfield
------------------------------------
on Validate
local tPassword
-----
put the uPassword of me into tPassword
replace numToChar(126) with numToChar(34) in tPassword -- replace "~" by a quote
put tPassword into fld "ClearString"-- displays the clear string
put tPassword into NewPassword
end Validate
=================================================
button named submit: (I wrote this. Does not work properly. I changed the username and password for now for obvious reasons)
=================================================
on mouseUp
if the text of field fldUserName is "username" and the text of NewPassword is "password" then
go to page Admin
else
answer "Wrong username or password"
end if
end mouseUp
=================================================
Now, how can I make this work? Thanks.
Mike
Here is the code for all of it:
field named fldUserName (has no code)
field named fldPassword1: (code written by someone else to create a proper password entry box)
=================================================
on mouseenter
set the text of field "lblHints" to "Enter your password - this field is mandatory!"
end mouseenter
on mouseleave
set the text of field "lblHints" to empty
end mouseleave
on rawKeydown pKey
local tChunk,tPassword
-----
if pKey = 65288 then -- delete key
put word 1 to 4 of the selectedChunk into tChunk
put the uPassword of me into tPassword
if word 2 of tChunk > word 4 of tChunk then
put word 4 of tChunk into word 2 to 4 of tChunk
end if
do "put empty into" && tChunk && "of tPassword"
set the uPassword of me to tPassword
pass rawKeydown
else pass rawKeydown
end rawKeydown
------------------------------------
on keyDown pKey
local tChunk,tPassword
-----
if the selectedChunk = empty then pass keyDown
put word 1 to 4 of the selectedChunk into tChunk
put the uPassword of me into tPassword
put numToChar(42) into the selectedChunk -- numToChar(42): "*"
if chartonum(pKey) = 34 then -- replace any quote by "~"
do "put numToChar(126) into" && tChunk && "of tPassword"
else do "put" && quote & pKey & quote && "into" && tChunk && "of tPassword"
set the uPassword of me to tPassword
end keyDown
------------------------------------
on enterInfield
Validate --
end enterInfield
------------------------------------
on returnInfield
Validate --
end returnInfield
------------------------------------
on Validate
local tPassword
-----
put the uPassword of me into tPassword
replace numToChar(126) with numToChar(34) in tPassword -- replace "~" by a quote
put tPassword into fld "ClearString"-- displays the clear string
put tPassword into NewPassword
end Validate
=================================================
button named submit: (I wrote this. Does not work properly. I changed the username and password for now for obvious reasons)
=================================================
on mouseUp
if the text of field fldUserName is "username" and the text of NewPassword is "password" then
go to page Admin
else
answer "Wrong username or password"
end if
end mouseUp
=================================================
Now, how can I make this work? Thanks.
Mike