[thelist] Accessing a CGI script from a PHP page

Max Schwanekamp lists at neptunewebworks.com
Thu Aug 3 12:13:44 CDT 2006


> From: Dave M G 
> I'm writing a PHP script that has a form which accesses a CGI 
> script on 
> an external web site.
> What I have for the <form> tag is:
> echo "<form method=\"uri\" 
> action=\"http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic?9MGI\">";

Hm, "URI" is not a valid value for the method attribute, AFAIK.  W3C seems
to confirm this[0].  However most browsers will default to the "GET" method
(which I think is what you want), so that's probably not the problem.

> When I test my script in my FireFox browser, I get a pop up window 
> asking me what to do with a "bin" file. I click to save it, 
> and I get a 
> file called "wwwjdic" on my desktop.
> I'm a little lost here. Is this a problem of PHP not knowing 
> what to do 
> with the returned output? Is it an issue with the script at 
> monash.edu.au that I need to contact the developer about? Is it 
> something do to with how the form action is structured?

So the script at monash.edu.au is returning binary data rather than
something textual, e.g. XML.  Yes, you should contact the developer about
it.  Your script will need to know what format the returned output will be
in, before that data can be coherently parsed.  In any case, how is this
related to PHP?

Oh, OK, I poked around a bit at that site, and it appears your action URL is
incorrect:
http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic?9MGI
Should be:
http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?9MGI

If you can get a coherent response from the server via your browser, you
should be able to figure out how to parse it in PHP fairly easily.

[0] http://www.w3.org/TR/html4/interact/forms.html#h-17.3

-- 
Max Schwanekamp
http://www.neptunewebworks.com/





More information about the thelist mailing list