Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: works for GET, not POST

From: gjones05:mail:orion at: 30-Jan-2001 16:41

Hi, Ryan, It can be frustrating sometimes. I just got the following code running on Windows 98, with Apache 1.3.14. The form file is arbitrarily named "rebolcgiform2.html". Place it in a web-accessible directory. <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"> <TITLE>untitled</TITLE> </HEAD> <BODY BGCOLOR="white"> <FORM ACTION="/cgi-bin/query.r" METHOD="POST"> <H2><FONT FACE="Arial, Helvetica">CGI Form Example</FONT></H2> <P> <TABLE BORDER="1" CELLSPACING="1" WIDTH="75%" BGCOLOR="silver"> <TR> <TD WIDTH="9%" BGCOLOR="#66CCFF"> <P ALIGN="RIGHT"><B>Name:</B> </TD> <TD><INPUT TYPE="TEXT" NAME="name" SIZE="40"></TD> </TR> <TR> <TD WIDTH="9%" BGCOLOR="#66CCFF"> <P ALIGN="RIGHT"><B>Email:</B> </TD> <TD><INPUT TYPE="TEXT" NAME="email" SIZE="40"></TD> </TR> <TR> <TD WIDTH="9%" BGCOLOR="#66CCFF"> <P ALIGN="RIGHT"><B>Phone:</B> </TD> <TD><INPUT TYPE="TEXT" NAME="phone" SIZE="20"></TD> </TR> </TABLE> </P> <P><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit"> </FORM> </BODY> </HTML> Now, the REBOL script file is arbitrarily named "query.r". Place it in the cgi-bin directory. #!c:/program files/rebol/rebol -cs REBOL [] retrieve-user-data: func [] [ return decode-cgi either system/options/cgi/request-method = "POST" [ data: make string! 2002 foreach line copy system/ports/input [ repend data [line newline] ] ][ either system/options/cgi/query-string [ system/options/cgi/query-string ][ "" ] ] ] print "Content-Type: text/html^/" print [ <HTML><BODY> {Here is the posted data.} <HR><PRE>(retrieve-user-data)</PRE> </BODY></HTML> ] If another directory has been designated as the executable directory, then you will need to change the path in the form. The path to rebol located at the top of the script may need to be changed depending on the platform. The webserver may need to be configured to accept the .r extension as an executable file, especially on Windows. If on UNIX, the file permissions will need to be changed to allow for reading and execution. If you cannot change the executable extension configuration, you may wish to change the executable extension to .cgi, since many hosts have this extension preconfigured (in this case you will also need to change the named path to the script in the form). Hopefully this will work. If it doesn't, then there is a problem with the configuration. Let us know what platform and webserver you are using, and whether you have access to the configuration file. Good luck! --Scott