Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 1998 10:47:46 +0000 (GMT)
From:      "Jeremy D. Hartley" <ringlord@www.dcoisp.net>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Could I please get some help on a cgi script?
Message-ID:  <Pine.BSF.3.96.980330104009.12459A-100000@www.dcoisp.net>

next in thread | raw e-mail | index | archive | help
Greetings.
First off, I know that cgis are not the topic of freebsd list usually.
I have however had really good luck from many folks on this list, and I am
really in a bit of a jam, and any help I can get would be greatly
appreciated.
Over the last several days, I have been given the task of creating a huge
website by next week, and it requires a lot of learning things on the fly.
Anyway, I have been teaching myself cgi writing, in perl.
I am including the text of the cgi script in the body of the message,
along with the html form I have created.
It is inportant to note that the form seems to work correctly, after I
pointed the action attribute to the test cgis on ncsa's webserver.
However, my cgi seems to return every value except the last one!  That is
where the problem is, and I am hoping someone can assist me.

CGI script:

#!/usr/bin/perl
&readparse;
print "Content-type:text/html\n\n";
print "<html><head><title>Form results</title></head><br>";
print "The information you submitted is included below.<br>";
print "In order to complete your order, please print and send this form and
send it to us.";
$firstname = $value[0];
$lastname = $value[1];
$address1 = $value[2];
$address2 = $value[3];
$city = $value[4];
$state = $value[5];
$zip = $value[6];
$phone = $value[7];
$fax = $value[8];
$email = $value[9];
$comments = $value[10];
$single = $value[11];
$double = $value[12];
$tripple = $value[13];
$grand = $value[14];
$sports = $value[15];

print "First name: $firstname<br>";
print "Last name: $lastname<br>";
print "Address: $address1<br>";
print "$address2<br>";
print "City: $city<br>";
print "State: $state<br>";
print "zip is: $zip<br>";
print "Phone: $phone<br>";
print "fax: $fax<br>";
print "e-mail: $email<br>";
print "comments: $comments<br>";
print "plan: $single $double $tripple $grand<br>";
print "sports: $sports<br>";

sub readparse {
read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'});
if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}};
$user_string =~ s/\+/ /g;
@name_value_pairs = split(/&/,$user_string);
foreach $name_value_pair (@name_value_pairs) {
        ($keyword,$value) = split(/=/,$name_value_pair);
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge;
        push(@value, "$value");
          $user_data{$keyword} = $value;
}
}


HTML form:
<html><head><title>Join the Informer Today!</title></head>
<h2>Join the Fantasy Sports Informer Today!</h2>

<body>
<p>
Here at FSI, we give you many ways to participate in the sports you
love.<br>

If you wish to pay with your Visa or Mastercard, more information is
availible by clicking <a href="http://www.fantasysportsinformer.com/credit.html">here.</a>;

<p>
Folks wishing to pay by check or money order may do so by completely filling
out the form below.<br>
After you complete the form, a copy will be e-mailed to the address you
specified on the form.  Simpley print out the completed form and send it to
the address provided when you submit the form to us.<br>

<br>
<h3>ORDER FORM</h3>
<br>

<form action="cgi-bin/order.cgi" " method=post>
<br>
<p>
First name: <input type=text size=25 name="first"><br>
Last name: <input type="text" size=25 name="last"><br>
Street address, line 1: <input type=text size=40 name="address_1"><br>
Street address, line 2: <input type=text size=40 name="address_2"><br>
City: <input type=text size=45 name="city"><br>
Enter your 2 letter state code (CA California) <input maxlength=2 name="state"><br>

Enter your Zip or postal code: <input type=text maxlength=9 name="zip"><br>
Phone number (777-555-1212) <input maxlength=16 name="phone"><br>
Fax number: (777-555-1212) <input maxlength=17 name="fax"><br>
E-mail address: <input type=text size=25 name="email"><br>

Where did you hear about us? <input type=text name="comments"><br>
<p>
<h2>CHOOSE YOUR PLAN</h2>
Which of the four plans do you wish to signup for?

<input type=radio name="plan" value="single">Single Sport

<input type=radio name="plan" value="doubleplay">Doubleplay two sport plan<br>
<br>
<br><input type=radio name="plan" value=tripleplay">Trippleplay 3 sport plan<br>
<input type=radio name="plan" value="grandslam">Grandslam 4 sport plan<br>
What other sports do you like? <input type=text name="sports"><br>
<p>
<input type=submit value="submit this form."><br>
<input type=reset value="reset and start over."><br>
</form>
</body</html>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980330104009.12459A-100000>