Computer Science Canada

password and username program problem

Author:  vdragon88 [ Wed Jan 07, 2004 5:52 pm ]
Post subject:  password and username program problem

username and password check...
if it fails let the person try 3 times.

I dont know how to do it
plz help

Author:  Thuged_Out_G [ Wed Jan 07, 2004 5:57 pm ]
Post subject: 

heres your only freebie you'll get...from me atleast lol

code:

const username:="username"
const pwd:="password"
var uname:string
var passw:string
var count:=0
var win:=Window.Open("position:top,center,graphics:300;200")

proc userLogin
loop
put "Enter username"
get uname

if uname=username then
put "Correct username"
return
else
put "Access Denied"
count +=1
end if

if count=3 then
loop
Window.Close(win)
end loop
end if
end loop
end userLogin

proc userPwd
loop
put "Now enter the password"
get passw

if passw=pwd then
put "Login succesful"
return
else
put "Acess Denied"
count +=1
end if

if count=3 then
loop
Window.Close(win)
end loop
end if
end loop
end userPwd

userLogin
userPwd


there you go, you got yourself to login procedures

PS, if you get a problem with the "return" part of the procedure(im not sure about it) just replace return with "exit"

Author:  DanShadow [ Thu Jan 08, 2004 11:26 am ]
Post subject: 

Also you could have it, that it saves the logins, and when the user types in the password/username, it loads from disk. Something like this:
code:

var datafile:int
var uname,upass,name,pass:string:=""
open :datafile, FiLeNaMe:get
get:datafile,name
uname:=name
put "Enter user name: "..
get name
if name=uname then
get:datafile,pass
put "Welcome ",name,", enter password: "..
get upass
if upass not=pass then
put "Password incorrect."
break
else
put "Login Accepted."
end if
elsif name not=uname
put "Username incorrect."
break
end if


: