By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

Problem linking html and cgi together

100+
P: 170
hey guys, this is something on html and cgi taken from some example on the net
but i got problem getting it work
the html code is:

Expand|Select|Wrap|Line Numbers
  1.  <HTML>
  2.         <HEAD>
  3.           <TITLE>HTML Form Example</TITLE>
  4.         </HEAD>
  5.         <BODY>
  6.           <FORM method="GET" action="c:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/lesson2.pl">
  7.             <h3>Your First Name:</h3>
  8.             <p><INPUT type="text" name="FirstName"></p>
  9.             <h3>Your Last Name:</h3>
  10.             <p><INPUT type="text" name="LastName"></p>
  11.             <h3>Check if you are a student:</h3>
  12.             <p><INPUT type="checkbox" name="isStudent"></p>
  13.             <h3>What is your gender?</h3>
  14.             <p>
  15.               <INPUT type="radio" name="Gender" value="isMale">Male
  16.               <INPUT type="radio" name="Gender" value="isFemale">Female
  17.             </p>
  18.             <h3>How many moons are there on your planet?</h3>
  19.             <p>
  20.             <SELECT name="numMoons" size="5">
  21.               <OPTION value="1" selected>Only One Moon
  22.               <OPTION value="2">Two Nice Moons
  23.               <OPTION value="3">A Fine Triplet
  24.               <OPTION value="4">Four Celestial Bodies
  25.               <OPTION value="5-8">Between Five and Eight
  26.               <OPTION value="9-12">We Have Between Nine and Twelve
  27.               <OPTION value="lots">Too Many To Count!
  28.             </SELECT>
  29.             </p>
  30.             <h3>Comments:</h3>
  31.             <p><TEXTAREA rows="10" cols="80">Type Comments Here</TEXTAREA></p>
  32.             <h3>Hidden Data!</h3>
  33.             <p><INPUT type="hidden" name="Secret" value="Invisible"></p>
  34.             <h3>Submit this Form</h3>
  35.             <p><INPUT type="submit" value="Send Data Now!"></p>
  36.             <h3>Reset this Form</h3>
  37.             <p><INPUT type="reset" value="Clear all my input now"></p>
  38.         </FORM>
  39.       </BODY>
  40.     </HTML>
  41.  
and the cgi script is
Expand|Select|Wrap|Line Numbers
  1. #!/perl/bin/perl
  2.  
  3. use strict;
  4. use CGI;
  5. my $cgi = new CGI;
  6. print
  7.     $cgi->header(),
  8.     $cgi->start_html( -title=>'Form Results',
  9.               -author=>'Craig Kelly'),
  10.     $cgi->h1('Form Results'), "\n";
  11. my @params=$cgi->param();
  12. print '<TABLE border="1" cellspacing="0" cellpadding="0">', "\n";
  13. foreach my $parameter (sort @params){
  14.     print "<tr><th>$parameter</th><td>", $cgi->param($parameter), "</td></tr>\n";
  15.     }
  16.     print "</TABLE>\n";
  17.     print $cgi->end_html;
  18.     exit(0);
  19.  
the html form is supposed to feed all the parameters into my cgi script
but each time i click on my submit button,
instead of bringing me to the page with my tables and results
it's giving me a prompt of weather i wanna open the lesson2.pl script
any idea why?
May 23 '08 #1
Share this Question
Share on Google+
2 Replies


KevinADC
Expert 2.5K+
P: 4,059
this can't be correct:

Expand|Select|Wrap|Line Numbers
  1. action="c:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/lesson2.pl"
the action attribute points to a URL, not the directory where the script is. Generally you use "localhost" for a local install of apache:

Expand|Select|Wrap|Line Numbers
  1. action="localhost/cgi-bin/lesson2.pl"
May 23 '08 #2

100+
P: 170
this can't be correct:

Expand|Select|Wrap|Line Numbers
  1. action="c:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/lesson2.pl"
the action attribute points to a URL, not the directory where the script is. Generally you use "localhost" for a local install of apache:

Expand|Select|Wrap|Line Numbers
  1. action="localhost/cgi-bin/lesson2.pl"
yepz...got it
alright thanks for the advice on the directory change
May 26 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.