166
ScriptBasic Examples w/source / Password Entry Example
« on: March 26, 2006, 08:28:43 PM »
http://www.scriptbasic.org/cgi-bin/getpswd.bas
Code: [Select]
#!/usr/bin/scriba -c
INCLUDE cgi.bas
OPTION cgi$Method cgi::Post or cgi::Get
IF cgi::RequestMethod()="GET" THEN
max_tries = 5
tryno=1
mypass = ""
END IF
IF cgi::RequestMethod()="POST" THEN
IF cgi::PostParam("mypass")="LetMeIn" THEN
cgi::Header 302,"text/html"
PRINT "Location: /private.html\n"
cgi::FinishHeader
END
END IF
max_tries=cgi::PostParam("max_tries")
tryno=cgi::PostParam("tryno")
tryno = tryno + 1
IF tryno > val(max_tries) THEN
cgi::Header 302,"text/html"
PRINT "Location: /home.html\n"
cgi::FinishHeader
END
END IF
END IF
cgi::Header 200,"text/html"
cgi::FinishHeader
PRINT """
<html>
Try number """ & tryno & """<br>
Enter Passsword:
<form method=post action=/cgi-bin/getpswd.bas>
<input type=password name=mypass size=10>
<input type=submit value="Go">
<input type=hidden name=max_tries value=""" & max_tries & """>
<input type=hidden name=tryno value=""" & tryno & """>
</form>
</html>
"""
END
--------------------------[home.html]------------------------------
<html>
<h1>Home Page</h1>
</html>
--------------------------[private.html]----------------------------
<html>
<h1>Private Page</h1>
</html>