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
SOLVED - Trying to create a simple hard coded admin login
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
SOLVED - Trying to create a simple hard coded admin login
Last edited by admin12 on Mon Aug 01, 2011 6:47 am, edited 1 time in total.
Re: Trying to create a simple hard coded admin login
Hi.
I am probably missing the whole point of your post.
But can you say again what you are trying to do? To manage a permission of some kind to open an application with LC?
Craig Newman
I am probably missing the whole point of your post.
But can you say again what you are trying to do? To manage a permission of some kind to open an application with LC?
Craig Newman
Re: Trying to create a simple hard coded admin login
This part does not work:dunbarx wrote:Hi.
I am probably missing the whole point of your post.
But can you say again what you are trying to do? To manage a permission of some kind to open an application with LC?
Craig Newman
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
I am trying to make it work.
Mike
Re: Trying to create a simple hard coded admin login
Hi Mike,
you really need to get the grips of the basics of LiveCode!
In case I did not mention this before:
http://www.runrev.com/developers/lesson ... nferences/
This will work if the user entered the strings "username" and "password"???
So I guess this might be variables, right?
In that case you must not put them in quotes, and they are not defined, neither local nor global!
Names should be in quotes however -> fld "fldUserName"
Best
Klaus
you really need to get the grips of the basics of LiveCode!
In case I did not mention this before:
http://www.runrev.com/developers/lesson ... nferences/

You missed -> ... the text of FIELD "NewPassword"...admin12 wrote:if the text of field fldUserName is "username" and the text of NewPassword is "password" then
This will work if the user entered the strings "username" and "password"???
So I guess this might be variables, right?
In that case you must not put them in quotes, and they are not defined, neither local nor global!
Names should be in quotes however -> fld "fldUserName"
The LiveCode metaphore is CARD/CARDS -> go card "Admin"admin12 wrote:go to page Admin
Best
Klaus
Re: Trying to create a simple hard coded admin login
By the way, in utilizing the above code, the only text I get for the password fields are the asteriks.
I am using tPassword. uPassword does not give me anything either.
Any suggestions?
Mike
I am using tPassword. uPassword does not give me anything either.
Any suggestions?
Mike