Help with basic CGI project?

John Patten johnpatten at mac.com
Wed Jun 18 13:07:31 EDT 2008


Hi All?

I been going round and round with an issue on a very simple cgi exercise. I?m attempting to post data from a web form and store it in a field on a rev stack.  Everything appears to work with the exception of saving text to a fld on the rev stack, saving new cards in the rev stack, and pulling text out of flds that are not on the first card of the stack.

I had this posted on the forum but then saw the post this morning on the list about more ?eyes? on the mailing list so I thought I?d try here too. :-)

Thank you Klaus, Mark, and Richard for jumping in so far!

Couple things I?ve noticed that seem a bit strange.  First, if I have multiple ?put? commands pulling text from fields on different cards, the rev cgi only will pull the text from the first card. If I add multiple fields to the first card, and pull the text from these fields, all on one card, it will pull the text out of the fields.  It is as if the rev cgi will not go beyond the first card of the data.rev stack.

Also, if I increase the number of  ?create new card? commands in the text cgi script, it will report back that it created the cards, but if it does, they are only temporary and not saved.

So here?s the description of what I have been doing:


One stack ? Data.rev  It contains three cds with one fld on each cd.

CGI text script-  postdata.cgi

#!rev
on startup
put "Data.rev" into theStack
put empty into theTerm
repeat until length(theTerm) = $Content_Length
read from stdin until empty
put it after theTerm
end repeat
if theTerm = "" then 
put "You don't have any data stupid!" into buffer
else if there is no stack theStack then
put "No stack of that name." after buffer
--put cr & theStack after buffer
else

put theTerm into theTermsArray
split theTermsArray by "&" and "="
put urlDecode(theTermsArray["terms"]) into theIdentifiedTerm
end if
put "content-Type: text/plain" & cr & cr 

put "number of cards:" & the number of cards of stack theStack & cr before buffer
set the destroyStack of stack theStack to true
set the defaultstack to theStack
create card
create card
create card
--it appears rev creates the cards, but they are not saved
put it
put "number of cards:" & the number of cards of stack theStack & cr before buffer
put buffer & cr & theIdentifiedTerm & cr & theStack & cr & cd fld "thedata2" of cd 2 of / stack theStack & cr & cd fld "theData" of cd 1 of stack theStack /

put theIdentifiedTerm into cd fld "theData2" of cd 1 of stack theStack

--put the result
--put cr & cd fld "thedata" of cd 1 of stack theStack after buffer
--put cr & cd fld "thedata2" of cd 2 of stack theStack after buffer
-put cr & cd fld "thedata3" of cd 3 of stack theStack after buffer

save stack theStack
put buffer
close stack theStack
quit rev
end startup


HTML Web Form- postdata.html


<html>
<head>
<title>Sending data to rev stack</title>
</head>
<body>
<form action="http://localhost/cgi-bin/postdata.cgi" method="post">
<p>
<h2>Send this data to the rev stack:</h2>
<p>
<input type="text" name="terms" value="enter text here" size="35">
<p>
<input TYPE="reset" VALUE="Reset"> <input type="submit" value="Send Text">
</form>
</body>
</html>

Permissions Set on ?server? ? (I am running this local on my Mac OS X laptop running 10.4.11)

d1q4sv51:/Library/WebServer/CGI-Executables johnpatten$ ls -l
total 5416

-rwxr-xr-x   1 johnpatt  admin        1044 Jun 18 09:10 Data.rev
-rwxr-xr-x   1 johnpatt  johnpatt      516 Jan  9  2004 echo.mt
-rwxrwxrwx   1 johnpatt  johnpatt     1353 Jun 18 09:43 postdata.cgi
-rwxr-xr-x   1 johnpatt  johnpatt  2698096 Apr 18  2003 rev



Also, I?m using the rev engine link that is on Jacqueline?s tutorial, http://downloads.runrev.com/engines/2.1.2/cgi/osx.zip

I used Rev 2.9 to create the data.rev stack and then did a Save as? and saved it in Legacy Mode.

If anybody sees anything I missed, I?d be greatly appreciative!

Thank you!




More information about the use-livecode mailing list