<FORM ACTION="http://mypage.whatever.com/cgi-bin/test.pl">
<P>Please specify the multiplicands:
<INPUT NAME="m" SIZE="5">
<INPUT NAME="n" SIZE="5"><BR>
<INPUT TYPE="SUBMIT" VALUE="Multiply!">
</FORM>
The "test.pl" is Borland C 4.53 dos exe renamed to test.pl (my site provider FAQ
said all scripts should be *.pl whether they are actually exes or perl):
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *data;
long m,n;
printf("%s%c%c","<html>",13,10);
printf("%s%c%c","<head>",13,10);
printf("<title>Multiplication results</title>\n");
printf("%s%c%c","<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=iso-8859-1\">",13,10);
printf("%s%c%c","</head>",13,10);
printf("%s%c%c","<body bgcolor=\"#FFFFFF\">",13,10);
printf("Multiplication results\n");
data = getenv("QUERY_STRING");
if(data == NULL)
printf("Error! Error in passing data from form to script.\n");
else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)
printf("Error! Invalid data. Data must be numeric.\n");
else
printf("The product of %ld and %ld is %ld.\n",m,n,m*n);
printf("%s%c%c","</body>",13,10);
printf("%s%c%c","</html>",13,10);
return 0;
}
But when I press the "multiply" button on the test.htm page I get the following
error:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP
headers. The headers it did return are:
Unrecognized character \240 ignored at F:\jfdjdfh\cgi-bin\testi.pl line 1.
Array found where operator expected at F:\\jfdjdfh\cgi-bin\testi.pl line 1, near
""
(Missing operator before ?)
syntax error at F:\\jfdjdfh\cgi-bin\testi.pl line 1, near ""
Unrecognized character \377 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \377 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \002 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \007 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \200 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \001 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \373 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \001 igno
What am I doing wrong?
--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content. You can SELF-APPROVE your first posting
by writing the word 'passme' on a line by itself.
2 things I notice here. First, your header is AFTER the html
and head tags, should be before. Second is that it needs to be
followed by 2 newline charachters. (usually \n).
Mark :)
"Drew Simonis" <car...@attglobal.net> wrote in message
news:393E5335...@attglobal.net...
: : #include <stdio.h>
:: #include <stdio.h>
:: #include <stdlib.h>
::
:: int main(void)
:: {
:: char *data;
:: long m,n;
:: printf("%s%c%c","<html>",13,10);
:: printf("%s%c%c","<head>",13,10);
:: printf("<title>Multiplication results</title>\n");
:: printf("%s%c%c","<meta http-equiv=\"Content-Type\" content=\"text/html;
:
:
:2 things I notice here. First, your header is AFTER the html
:and head tags, should be before. Second is that it needs to be
:followed by 2 newline charachters. (usually \n).
I checked a few HTML pages and they all had a similar composition like mine.
I'm just learning here and just want a "hello world" type of html page to
display.
I'll change the exe to write a htm page on the server and then make the browser
jump there. What is the HMTL or CGI command that the exe should printf()?
Read this:
http://hoohoo.ncsa.uiuc.edu/cgi/primer.html
Sharp! I didn't even notice that.
After? How about missing. That's a meta http-eqiv header, not an http
header.
Also, you don't need to print separate \n\r with most web servers -- the
server will rewrite the header and do that for you unless running nph?
--
Bill Moseley mailto:mos...@best.com
pls note the one line sig, not counting this one.
Those errors are clearly from perl, hopelessly trying to parse a
binary file as a Perl script. I think your provider's advice is
complete and utter bullshit.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
They must be the type that thing "CGI" eq "Perl"