SOLVED - Trying to create a simple hard coded admin login

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

SOLVED - Trying to create a simple hard coded admin login

Post by admin12 » 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
Last edited by admin12 on Mon Aug 01, 2011 6:47 am, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Trying to create a simple hard coded admin login

Post by dunbarx » Fri Jul 22, 2011 2:56 pm

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

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: Trying to create a simple hard coded admin login

Post by admin12 » Fri Jul 22, 2011 3:14 pm

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
This part does not work:

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trying to create a simple hard coded admin login

Post by Klaus » Fri Jul 22, 2011 3:54 pm

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/ 8)
admin12 wrote:if the text of field fldUserName is "username" and the text of NewPassword is "password" then
You missed -> ... the text of FIELD "NewPassword"...

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"
admin12 wrote:go to page Admin
The LiveCode metaphore is CARD/CARDS -> go card "Admin"


Best

Klaus

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: Trying to create a simple hard coded admin login

Post by admin12 » Mon Jul 25, 2011 7:16 pm

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

Post Reply