Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: cgi form data append to block
Pages: [1] Print
Author Topic: cgi form data append to block  (Read 844 times)
bsisoft
Newbie
*
Offline Offline

Posts: 2


View Profile
cgi form data append to block
« on: November 19, 2006, 02:19:35 PM »

Hi everyone, got a question, I'm obviously new to this but have been trying to play around with Rebol. Heres the question, I have the cgi script from the cgi2 example from http://www.rebol.com/docs/cgi2.html
it works great. I have a select form and what I am trying to do is append  the selection from the form to a block -- at the end of the block.  So what I mean is I can't figure out how to add a record that was selected from the cgi form to the end of a block, I have Rebol "the official guide" from Rebol Press and I can't find anything in there about how to do that with cgi. If it seems like a dumb question, oh well I'm new.
BTW does anyone know of an IRC channel for REBOL?
Any answers would be greatly appreciated, Thanks.
Logged
DideC
Newbie
*
Offline Offline

Posts: 36


View Profile
Re: cgi form data append to block
« Reply #1 on: November 21, 2006, 03:43:51 PM »

Hard to say with the info you provide.

If your script already load/save the block where you want to append the values, then just use 'append function.

If your formular will be used by many people, then prefer appending to the file that already contains the previous value ('write/append) , then load it to processs its content (if needed). Like this you will be free from managing concurent access.

Not sure I reply to your question, so feel free to give more details (code !) on what you want to achieve.
Logged
bsisoft
Newbie
*
Offline Offline

Posts: 2


View Profile
Re: cgi form data append to block
« Reply #2 on: November 21, 2006, 07:23:49 PM »

DideC thanks for replying - I would have given more info but wasn't sure exactly what would be needed - but here goes.

------------------------------------------------------------------------------
This is what I have for the CGI script
----------------------------------------------------
#! c:/program files/easyphp1-8/cgi-bin/REBOL -cs
REBOL []
print "Content-type: text/html^/"

html: make string! 2000
emit: func [data] [repend html data]

read-cgi: func [
    ;Read CGI data. Return data as string or NONE.
    /local data buffer
][
    switch system/options/cgi/request-method [
        "POST" [
            data: make string! 1020
            buffer: make string! 16380
            while [positive? read-io system/ports/input buffer 16380][
                append data buffer
                clear buffer
            ]
        ]
        "GET" [data: system/options/cgi/query-string]
    ]
    data
]

emit [
    <HTML><BODY BGCOLOR="#FFC080">
    <H2> "Form:" </H2>
    "Submitted: " now <BR>
    "REBOL Version: " system/version <P>
    <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5">
]

foreach [var value] decode-cgi read-cgi [
    emit [<TR><TD> mold var </TD><TD> mold value </TD></TR>]
]

emit [</TABLE></BODY></HTML>]
print html

---------------------------------------------------------------------------------------
Here is the html page with the form:
---------------------------------------------------------------------------------------
<html><head><title>select from form</title>
<base target="main">
</head>
<body>
<FORM ACTION="http://www.website-whatever.com/cgi-bin/test.cgi"
METHOD="POST">

<P>
<font>Select: <BR>
<select name="20" multiple size="15">
<option value="widget1">widget 1</option>
<option value="widget2">widget 2</option>
<option value="widget3">widget 3</option>
<option value="widget4">widget 4</option>
<option value="widget5">widget 5</option>
<option value="widget6">widget 6</option>
<option value="widget7">widget 7</option>
<option value="widget8">widget 8</option>
<option value="widget9">widget 9</option>
<option value="widget10">widget 10</option>
<p>
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Select">
-----------------------------------------------------------------------------------
here is the block data.r that I want to append to.
-----------------------------------------------------------------------------------

REBOL[]
widgets: [
   "widget1"
   "widget3"
   "widget8"
   ]
------------------------------------------------------------------------------------
so basically I am trying to get the widget selected in the form to be appended to the end of the widgets (data.r) block, when someone clicks on the submit button.

Thanks for any help...
Logged
Graham
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: cgi form data append to block
« Reply #3 on: November 22, 2006, 12:08:55 AM »

Your cgi script needs to load up the data.r file so that it has the widgets block.

It then needs to simply append the posted data to the block using append, and then write the data.r out again.

Note that if more than one cgi script accesses the data.r file, one of the changes will be lost.
Logged

Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: cgi form data append to block
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2008, 08:22:57 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2311 Posts in 595 Topics by 4144 Members
Latest Member: FinoDiato

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc