Click to See Complete Forum and Search --> : html drop-down to work with perl script?


jwisneski2003
09-29-2005, 08:33 AM
hello all,

i have a simple html form to which i want to add a select (drop down list)
the following html code works fine with the cgi-script untill i add a select box to it... when i add the drop down list to the html form of course it works but no combination of $name , or $selectname, etc that i add to the corresponding cgi-script will get the script to recognize the html code as it does the other code (the input text box's) MY QUESTION...how can this or any select name (drop-down) box be added to my form so it will run, or what do i have to add to the cgi-script thanks john

P.S. i have uploaded the associated cgi-lib file as a text file being over 10K total i couldn,t put it here directly


<html>
<body>
<form action="./cgi-bin/confirm.cgi" method="post">

<h3>This form sends an e-mail </h3>
Name:<br>
<input type="text" name="name"
value="" size="20">
<br>
Mail:<br>
<input type="text" name="email"
value="" size="20">
<br>
Comment:<br>
<input type="text" name="comment"
value="" size="40">
<br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">

</form>
</body>
</html>


#!/usr/bin/perl

require "cgi-lib.pl";

&ReadParse(*input);
$name=$input{'name'};

$email=$input{'email'};
$comment=$input{'comment'};

$remote_addr=$ENV{'REMOTE_ADDR'};
$remote_host=$ENV{'REMOTE_HOST'};
$remote_ident=$ENV{'REMOTE_IDENT'};
$remote_user=$ENV{'REMOTE_USER'};
$browser=$ENV{'HTTP_USER_AGENT'};
$date=`date`;
chop($date);

##
## Print HTML Header
##

print <<BLOCK_O_TEXT;
Content-type: text/html

<html>
<head>
<title>CSET 4100 - CGI Example</title>
</head>
<body>

<CENTER>
<p>&nbsp;</p>
<Font size=+1><b>$name, your form data has been sent collected.<br><br>
Thank you from john wisneski </Font></b>
</CENTER>
<p>&nbsp;</p>
BLOCK_O_TEXT

print "Today's Date: $date<p>";

print "Complete Name: $name, $name<br>";
print "Email: $email<p>";
print "comment: $comment<p>";
print "</BODY>\n";
print "</HTML>\n";


#when your program is working, add my email address
#open (MAIL, '|mail tkoluch@UTN.UToledo.edu, jwisneski2003@yahoo.com');
open (MAIL, '|mail jwisneski2003@yahoo.com');
select(MAIL);
print "\n";
print "A visitor from the remote host: $remote_host\n";
print "Located at IP address: $remote_addr\n";
print "Completed the form on: $date\n\n";
print "------------------------------------------------------\n\n";

print "FORM CONFIRMATION\n\n";

print "Complete Name: $name, $name\n";
print "Age: $age\n";
print "comment $comment\n";
print "Email: $email\n\n";

print "\n";
select(STDOUT);
close (MAIL);

<select name="cars">
<option value="volvo">Volvo
<option value="saab">Saab
<option value="fiat">Fiat
<option value="audi">Audi

Jeff Mott
09-29-2005, 08:57 PM
I don't actually see a select menu in your HTML form anywhere. You should be able to access it's value in the CGI script the same as any other. If you show us what you have actually tried we may be able to show you where it has gone wrong.

Also note that the cgi-lib library has been replaced by the CGI module for roughly a decade. Unless there is a very good reason you need to program for the world of Perl 4 you probably should update your programming practices. See the sticky thread "Learn Perl...." for places to get good Perl information.

Nedals
09-29-2005, 11:20 PM
Name<br><input type="text" name="name" value="" size="20"><br>
Mail:<br><input type="text" name="email" value="" size="20"><br>
Comment:<br><input type="text" name="comment" value="" size="40"><br>

Work with...
my $name=$input{'name'};
my $email=$input{'email'};
my $comment=$input{'comment'};

<select name="dropdown">
<option value=1>...
etc
</select>
Will work with...
my $dropdown_value=$input{'dropdown'};

BUT always
use strict;

and, as Jeff suggested,
use CGI;