anilhpn has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have written html code which has to operate based on a perl cgi file. I stored that in /var/www/cgi-bin/ folder. I have given the same path in the html page. That CGI script needs to connect to a MySQL server. I have written every thing. But whenever I click on any button it is taking me the perl CGI script. Not operating accordingly.

I am new to this CGI scripting. So, kindly guide me.

HTML Code:
<hr> <form name="node" action="/home/anil/Desktop/displayPort.cgi" method=" +POST"> <input type="radio" name="choice" value="add"> Add <input type="radio" name="choice" value="del"> Delete <input type="radio" name="choice" value="display"> Display <input type="radio" name="choice" value="update"> Update <input type="submit" value="ClickMe"> </form>
Cgi Code (currently I am not doing any operation as I felt the integration between html page and the cgi script is not proper):
#!/usr/bin/perl use DBI; use CGI; print "Content-type:text/html\r\n\r\n"; print "<title>Updation\\Display</title>"; print "<body bgcolor=\"#98AFC7\">"; $query = new CGI; print "Content-type: text/html\n\n"; print <<EOF; <HTML> <HEAD> <TITLE>Hello, world!</TITLE> </HEAD> <BODY> <H1>Hello, world!</H1> </BODY> </H
My main requirement is when I click on any button mentioned in above should lead me to that operation. So suggest me what kind of code I need to add in the cgi script and how do I integrate it with a sql server. Thanks! Anil A Kumar

Replies are listed 'Best First'.
Re: Perl CGI and DB Integration
by zentara (Cardinal) on Sep 16, 2011 at 10:36 UTC
    But whenever I click on any button it is taking me the perl CGI script. Not operating accordingly.

    That is what you are telling it to do. What did you expect it to do? You should post a minimal bit of code, showing the html form, and the cgi script code. Include the part that connects to the db.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Perl CGI and DB Integration
by keszler (Priest) on Sep 16, 2011 at 11:03 UTC

    Assuming that you're running an Apache webserver, is it configured for Perl?

    LoadModule cgi_module modules/mod_cgi.so ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" <Directory "/var/www/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> AddHandler cgi-script .cgi .pl DirectoryIndex index.html index.html.var index.cgi index.pl

    Update: Now that you've posted your form we can better diagnose. For example, your form's action sends it to "/home/anil/Desktop/displayPort.cgi". When you click "ClickMe", can the webserver access /home/anil/Desktop/displayPort.cgi? Does Apache's configuration file have a ScriptAlias /cgi-bin/ "/home/anil/Desktop/" line?

Re: Perl CGI and DB Integration
by zentara (Cardinal) on Sep 16, 2011 at 16:58 UTC
Re: Perl CGI and DB Integration
by jethro (Monsignor) on Sep 16, 2011 at 10:38 UTC