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

----- Original Message -----
From: "Ryan C. Christiansen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 30, 2001 11:22 AM
Subject: [REBOL] Re: works for GET, not POST


> I'm still lost on how to use POST to create an object! containing the
> values submitted in a form. The following function creates a string!
> value called 'data, correct?
>
> retrieve-user-data: func [] [
>     either system/options/cgi/request-method = "POST" [
>    data: make string! 2002
>     read-io system/ports/input data 2000
>     ][
>         cgi: make object! decode-cgi-query
>  system/options/cgi/query-string
>     ]
> ]
>
> The /Core user's guide says "a good format for POST data is to use
> a REBOL dialect and create a simple parser. The POST data can be
> loaded and parsed as a block."
>
> Why isn't there a built-in function for parsing POST data into an
> object? Am I missing something?
>
> -Ryan
>
> > Ryan,
> >
> > It appears as though you will need to read from system/ports/input to
> > receive the actual POST query data.  This process is explained in more
> > detail in the "REBOL/Core User's Guide," which is available in pdf
> > format online at:
> >
> > http://www.rebol.com/download_manual.html
> >
> > or the print version is available through www.rebolpress.com  .
> >
> > The relevent section begins on page 402, with POST explained on the
> > following two pages.
> >
> > Hope this helps.
> >
> > - Scott
> >
> > ----- Original Message -----
> > From: "Ryan C. Christiansen" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, January 19, 2001 5:19 PM
> > Subject: [REBOL] works for GET, not POST
> >
> >
> > > I'm using the following function, which is derived from the "Official
> > > Guide," for CGI.
> > >
> > > retrieve-user-data: func [] [
> > >     return make object! decode-cgi
> > >     either system/options/cgi/request-method = "POST" [
> > >         input
> > >     ][
> > >         system/options/cgi/query-string
> > >     ]
> > > ]
> > >
> > >
> > > I use it as such:
> > >
> > > cgi-input: retrieve-user-data
> > >
> > > to give me an object containing the input values.
> > >
> > > My usage is working for GET operations but not for POST. What am
> > > I doing wrong?
> > >
> > > -Ryan
> > > --
> > > To unsubscribe from this list, please send an email to
> > > [EMAIL PROTECTED] with "unsubscribe" in the
> > > subject, without the quotes.
> > >
> >
> > --
> > To unsubscribe from this list, please send an email to
> > [EMAIL PROTECTED] with "unsubscribe" in the
> > subject, without the quotes.
> >
>
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to