ScriptBasic
February 08, 2012, 10:31:23 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: The ScriptBasic User, Developer and extension module guides are available at the WIKI.
 
   Home   Wiki Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Password Entry Example  (Read 1901 times)
support
Administrator
*****
Posts: 369


« on: March 26, 2006, 09:28:43 PM »

http://www.scriptbasic.org/cgi-bin/getpswd.bas

Code:

#!/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>
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!