I am new to CGI, I thought you people might be able to help me:
My HTML code:
--------
<HTML>
<HEAD>
<TITLE> CGI Multiplication Example </TITLE>
</HEAD>
<FORM ACTION="http://localhost/cgi-bin/mult.cgi" METHOD="GET">
<P> Please specify the multiplicands </P>
<INPUT name="m" SIZE="5">
<INPUT NAME="n" SIZE="5"><BR>
<INPUT type="SUBMIT" value="Multiply!">
</FORM>
<BODY>
</BODY>
</HTML>
--------
My C CGI Script code:
--------
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
char *data;
long m,n;
printf("Content-type: text/html\n\n");
printf("<TITLE> Multiplication results </TITLE>\n");
printf("<H2>Mutliplication results</H2>\n");
data = getenv("QUERY_STRING");
if(*data == ' ')
printf("<P>ERROR</P>");
else
if(scanf(data,"m=%1d&n=%1d",&m,&n)!=2)
printf("<P>ERROR</P>");
else
printf("The product of %1d and %1d is
%1d",m,n,m*n);
return 0;
}
-----------
Now when I run my HTML, it is giving Internal Server Error, I am using
Apache Web Server below is error message that I have found in Error log
file:
----------
[Tue Sep 26 20:39:42 2006] [error] [client 127.0.0.1] (OS 5)Access is
denied. : couldn't create child process: 720005: MULT.cgi
[Tue Sep 26 20:39:42 2006] [error] [client 127.0.0.1] (OS 5)Access is
denied. : couldn't spawn child process: C:/Program Files/Apache
Software Foundation/Apache2.2/cgi-bin/MULT.cgi
----------
Please let me know where I am doing wrong!!
Thanks,
Chandra.
--
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.
HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
> I am new to CGI, I thought you people might be able to help me:
>
> My HTML code:
> --------
> <HTML>
> <HEAD>
> <TITLE> CGI Multiplication Example </TITLE>
> </HEAD>
> <FORM ACTION="http://localhost/cgi-bin/mult.cgi" METHOD="GET">
> <P> Please specify the multiplicands </P>
> <INPUT name="m" SIZE="5">
> <INPUT NAME="n" SIZE="5"><BR>
> <INPUT type="SUBMIT" value="Multiply!">
> </FORM>
> <BODY>
> </BODY>
> </HTML>
> --------
That's invalid HTML. Forms go inside the body element. That's *a* problem,
and you'll certainly want to fix that, but it's obviously not *the* problem
since your CGI appears to be getting called.
> My C CGI Script code:
Writing CGIs in C is what drove me to Perl. :-)
I don't see any immediate problem with it, although there's no reason you
should be parsing the form input for yourself. That can be a bit tricky in
places, and there are libraries to do it for you.
One of the better ones:
> Now when I run my HTML
Nit-Pick: You can't run HTML. It's markup, not programming.
>, it is giving Internal Server Error, I am using
> Apache Web Server below is error message that I have found in Error log
> file:
>
> ----------
> [Tue Sep 26 20:39:42 2006] [error] [client 127.0.0.1] (OS 5)Access is
> denied. : couldn't create child process: 720005: MULT.cgi
> [Tue Sep 26 20:39:42 2006] [error] [client 127.0.0.1] (OS 5)Access is
> denied. : couldn't spawn child process: C:/Program Files/Apache
> Software Foundation/Apache2.2/cgi-bin/MULT.cgi
> ----------
>
> Please let me know where I am doing wrong!!
Try giving your CGI an .exe extension. It's in /cgi-bin, so it shouldn't
need a .cgi extension for Apache to execute it as a CGI, and Windows may
not want to run it with a .cgi extension.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net