Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First Time CGI

Status
Not open for further replies.

wkpowers

IS-IT--Management
Feb 6, 2007
3
0
0
Running Windows 2000 and Apache.

ActivePerl is installed in C:\Perl\bin
CGI-Bin is located at C:\c-web\cgi-bin
Web is located at C:\c-web\
Permisions are set to allow everyone full access.

I've started with just a simple CGI script to collect usernames and emails. My website displays correctly but when I click submit on my form all I see is my .cgi script not the returned data I should be seeing. I think it's because I don't have the first line in the .cgi file correct.

Currently it is:
#!C:\Perl\bin\perl.exe

 
You need an http server if you want to run cgi scripts from a browser. Apache is free and there are many tutorails that explain how to set it up.


- Kevin, perl coder unexceptional! [wiggle]
 
Per my first post. I am running Apache. My websites are working fine. It's the CGI that is not.
 
Thanks for the link. I did have some permissions set incorrectly. But I still can't get the CGI to work. I get a 404 error saying the requested url is not found.



Below is my code:

FILE NAME: porequest.cgi

#!C:\Program Files\Perl\bin\perl.exe
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}


print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY BGCOLOR=#FFFFFF>\n";
print "<CENTER>\n";
print "THANK YOU<BR>\n";
print "$fields{fname} $fields{lname}</BR>";
print "I will write<BR>\n";
print "you at<BR>\n";
print "$fields{email}<BR>\n";
print "</CENTER>\n";
print "</BODY></HTML>";


FILE NAME: porequest.html

<HTML>
<BODY>
<FORM METHOD="POST" ACTION="/cgi-bin/porequest.cgi">
<PRE>
First Name <INPUT TYPE="text" NAME="fname" MAXLENGTH=15 SIZE=15>
Last Name <INPUT TYPE="text" NAME="lname" MAXLENGTH=20 SIZE=20>
E-Mail Addr <INPUT TYPE="text" NAME="email" MAXLENGTH=35 SIZE=35>
<INPUT TYPE="submit" VALUE="Send Mail!">
<INPUT TYPE="reset" value=" Clear-Form">
</PRE>
</FORM>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top