Writing CGI scripting using perl

Hi All,

I am trying to do the following thing.
I am entering name & email id & then in action i am calling a .cgi program that sends a email to the email id entered.
I am facing a small problem, once i have entered the details , its printing the contents of .cgi file in browser. there is a subroutine in program which prints the thank you note. it should give me that.

can anyone let me know where i went wrong.?

Thanks in advance.

Alma

As far as i know, this happens only under two situations:

  • http server may not be running.
  • cgi is not supported (i dont think this is common)

Thanks
Srini

I have restart my apache server .

I could find these enteries in the
#set Apache::PerlRun Mode for /cgi-perl Alias
<Location "/cgi-perl/*.pl">
SetHandler perl-script
PerlResponseHandler ModPerl::PerlRun
Options -Indexes ExecCGI
PerlSendHeader On
</Location>

how can i know the cgi is not supported ?

Thanks
Alma

For mod_perl, you have set the script executable, right? Also check Apache error log for more hints.

My code is a.html
<html>
<head>
<title></title>
<body>
<form name=name form method=post action=http://localhost/cgi-bin/b.cgi>
enter your name:<input name=name type=text><br>
<input type=submit>
</form>
</body>
</html>

b.cgi
#!/perl/bin/perl5.6.1.exe
use strict;
use CGI qw(:standard);
my $name=param("name");
print "Content-Type:text/html\n\n";
print $name;

But i am not getting the value in it.

Thanks Alma

Server is displaying source code because either there are problems with your mod_perl configuration, or your script is not properly installed (without +x chmod, lack of access permission, etc.), etc.

And your Apache configuration suggests you are not running Apache CGI (at least that's not what you quoted). You are running mod_perl.

Try changing the extension from .cgi to .pl and see if it helps. And did you actually give an executable chmod?

Yes it working fine now .
Thanks for the needed help.

There is a small query to raise.

I have a subscription html & subscription.cgi. On filling the subscription form , in action subscription. cgi will work n save the entered details . Once its filled then it should display another html page saying subscribed.

I have the html ready, i need to link them .
something like once subscibtion form is filled it need to display the subscribed .html & then to the Login page ..

meanwhile the data is stored using subscribed.cgi.

I am not sure how can i link these html n cgi ?

I will appreciate for the help..

Thanks

You should make sure you understand what CGI is, and watch out for some info about HTML form processing. Probably a bit of HTTP as well. That's quite a lot of content, and we can't explain everything here with just so tiny space.