87 posts
Posted 10 April 2012 - 11:52 PM
i need help to make a login program that will read the username and password form a file!
file eg.
user = user
password = password
like that and the login program will read it form a file can eny 1 help?
474 posts
Posted 11 April 2012 - 12:15 AM
Here:
function correct()
--CODE THAT HAPPENS WHEN PASSWORD IS CORRECT
end
if not fs.exists("//.pass")
write("New Password: ")
input = read("*")
local pass = fs.open("//.pass","w")
pass.write(input)
pass.close()
end
local hFile = fs.open("//.pass","r")
local password = hFile.readAll()
hFile.close()
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local ijkl = read("*")
if ijkl == (password) then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
correct()
sleep(1)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!")
print("Shutting down...")
sleep(1)
os.reboot()
end