There were some common MetaTalk errors in your script. Since the mc engine
doesn't pass these to the user in the browser, you have to double-check your
script, and build it up in (checked) working parts. I always align the
script to ensure consistency.
Sivakatirswami wrote/ schreef:
> #!/usr/local/bin/mc
> on start up
Should be: on startUp
> if $REQUEST_METHOD is "POST" then
> read from stdin until empty
For a some reason stdin as always empty with my script. The passed data is
in the environment variable $QUERY_STRING.
I always use this to get all the parts out the query string.
Case: $QUERY_STRING is "login=Sjoerd%20Op%20%27t%20Land&vote=4&age=14
Run this:
set itemdel to "="
put replaceText($QUERY_STRING,"&",return) into tQuery
repeat with i = 1 to the number of lines in tQuery
put urlDecode(item 2 of line i of tQuery) into \
qParameter[item 1 of line i of tQuery]
end repeat
Result:
qParameter["login"] = "Sjoerd Op 't Land"
qParameter["vote"] = "4"
qParameter["age"] = "14"
> put it into buffer
> put "Content-Type: text/plain" & cr
cr *does* work for me, I don't think you need a crlf
> put "Content-Length:" && the length of buffer & cr & cr
> put buffer
Forgot an "end if" here?
> end startup
>
> We installed it as "test_forms.cgi"
So, the script should be like this:
#!/usr/local/bin/mc
on startUp
if $REQUEST_METHOD is "POST" then
put $QUERY_STRING into buffer
else
put "Error: method should be POST" into buffer
end if
put "Content-Type: text/plain" & cr
put "Content-Length:" && the length of buffer & cr & cr
put buffer
end startUp
Hope this helps,
Sjoerd
Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.