I'm pretty new to CGI programming too, so I probably can't answer your
original question, but I would suggest that the first line of your script
be:

#!/usr/bin/perl -wT

The -w turns on warnings if your script does one of a list of things that
are screwy, like assigning a variable and never using it, writing to
read-only filehandles, using a string as a number, recursing past 100
levels, etc.  The -T turns on taint checking, which is a safety feature for
cgi scripts, and keeps you from using submitted form data within a shell
script without checking it first.  Your perl books will help a lot with
this.

That -w might help you find your error...  (or try typing "perl -cT
scriptname" at the command line to see if there are any errors).

I notice your page asks for a credit card # and claims to use SSL, but I
don't see the lock in my browser.  I'm still new to this like I said, but
this looks like an insecure way to do this...

- B




> Hi
> 
> I am very very new to perl. And after lots of work I did script a perl
> file to handle a online form (products order form). However, I am
> stuck at a point. I tried my best but could not get thru.
> 
> The form is located at: http://www.kevincoffey.com/order.htm
> 
> When I select a different shipping adrress, it DOESNOT work!
> 
> I gave a RADIO button for :
> 
> Shipping_Address: TRUE=SAME AS ABOVE (i.e. send to adove address)
> Shipping ADdress: FALSE = send to Floowing address
> 
> And in the followings cript I gave it with a -- if .. else --
> statement.. but no use..
> 
> Can someone pls help me?
> 
> Regards
> 
> Babul
> 
> And the first perl file is:
> ===form1.pl===
> 
> #!/usr/bin/perl
> 
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
> 
> my ($query, @params, $param, $paramVal);
> my ($csTravel);
> my (@allProductQuantities);
> my (@productIDs, $ID);
> my (@contactNameFields, @contactAddressFields, @contactOtherFields,
> $field, $value);
> my (@shippingNameFields, @shippingAddressFields, @shippingOtherFields);
> my ($productQuantity, $dollarValue);
> 
> $CGI::POST_MAX = 40000;
> $CGI::DISABLE_UPLOADS = 1;
> 
> $query = new CGI ();
> $query -> autoEscape (undef);
> 
> #Get all parameter-value pairs in a referenced hash
> @params  = $query->param ();
> @allProductQuantities  = grep (/^Quantity_for_Product/, @params);
> @productIDs = ();
> foreach $param (@allProductQuantities){
>        ($ID) = ($param =~ /^Quantity_for_Product_(.+)$/);
>        @productIDs = (@productIDs, $ID);
> }
> 
> =pod
> 
> $csTravel = "[EMAIL PROTECTED],[EMAIL PROTECTED]";
> open (MAIL, "|/bin/mail -s 'CTS Order' $csTravel");
> foreach $param (@params){
>    $paramVal = $query->param ($param);
>    if ($paramVal){
>        print MAIL $param, " = ", $paramVal, "\n";
>    }
> }
> 
> close (MAIL);
> =cut
> 
> @contactNameFields = qw(Contact_Title Contact_FirstName Contact_LastName);
> @contactAddressFields = qw( Contact_Organization
>        Contact_StreetAddress1 Contact_Address3 Contact_City1 Contact_State1
>        Contact_ZipCode1 Contact_Country1);
> #This variable is not used later
> @contactOtherFields = qw(Contact_WorkPhone Contact_FAX
>        Contact_Email);
> 
> @shippingNameFields = qw (Shipping_Title Shipping_FirstName
> Shipping_LastName);
> @shippingAddressFields = qw(Shipping_Organization
>        Shipping_StreetAddress   Shipping_Address2 Shipping_City
> Shipping_State
>        Shipping_ZipCode   Shipping_Country);
> 
> print $query->header();
> print $query->start_html(-title => 'Your CST Order',
>                                        -BGCOLOR => "white");
> print "<h2>Please check details of your order.</h2>\n";
> print qq{<h4><font color = "red">If everything looks OK, please click
> on the "Submit My Order" Button below.\n If not, please click on the
> "Back" button of your browser and make your corrections on the
> previous page.\n</font></h4>};
> print $query-> hr,
>    "<b>Your billing address is:</b><br>",
>    $query -> hr;
> 
> #start a form
> print "\n";
> print $query->start_form(-method=>"POST",
>                            -action=>"/cgi-bin/form2.pl");
> #Print contact name
> foreach $field (@contactNameFields){
>        $value = $query -> param("$field");
>        print "$value ";
>        print $query -> hidden (-name => "$field",
>                                -default => "$value",
>                                          );
>        print "\n";
> 
> }
> print $query -> br;
> 
> #Print contact address
> foreach $field (@contactAddressFields){
>        $value = $query -> param("$field");
>        if ($value){
>                print $value, $query -> br, "\n";
>        print $query -> hidden (-name => "$field",
>                                -default => "$value",
>                                          );
>        print "\n";
> 
>        }
> }
> print $query -> br, "\n";
> 
> #Print additional contact information
> $value = $query -> param("Contact_WorkPhone");
> if ($value){
>        print "Phone: ", $value, $query -> br;
>        print $query -> hidden (-name => "Contact_WorkPhone",
>                                -default => "$value",
>                                          );
>        print "\n";
> }
> 
> $value = $query -> param("Contact_FAX");
> if ($value){
>    print "Fax: ", $value, $query -> br, "\n";
>        print $query -> hidden (-name => "Contact_FAX",
>                                -default => "$value",
>                                          );
>        print "\n";
> }
> 
> $value = $query -> param("Contact_Email");
> if ($value){
>    print "Email: ", $value, $query -> br, "\n";
>    print $query -> hidden (-name => "Contact_Email",
>                                -default => "$value",
>                                          );
>    print "\n";
> }
> 
> print $query -> hr, "<b>Your shipping preference is:</b>",
>    $query -> hr;
> #print "Shipping_Preference", $query -> param ("Shipping_Preference"),
> "<BR>\n";
> $value = $query -> param("Shipping_Preference");
> if ($query -> param ("Shipping_Preference") == "TRUE"){
>        print "SEND TO ABOVE ADDRESS<br>\n";
> }
> else
> {       #A different shipping address
> 
> #Print contact name
>   foreach $field (@shippingNameFields){
>        $value = $query -> param("$field");
>        print "$value ";
>        print $query -> hidden (-name => "$field",
>                                -default => "$value",
>                                          );
>        print "\n";
>  }
>  print $query -> br, "\n";
> 
>  #Print shipping address
>  foreach $field (@shippingAddressFields){
>        $value = $query -> param("$field");
>        if ($value){
>                print $value, $query -> br, "\n";
>        print $query -> hidden (-name => "$field",
>                                -default => "$value",
>                                          );
>        print "\n";
>        }
>  }
>  print $query -> br, "\n";
> 
>  $value = $query -> param("Shipping_Phone");
>  if ($value){
>    print "Phone: ", $value, $query -> br, "\n";
>    print $query -> hidden (-name => "Shipping_Phone",
>                            -default => "$value",
>                                          );
>    print "\n";
>  }
> } #else ends
> 
> print $query -> hr, "<b>Details of your order are given below: </b>",
>    $query -> hr, "\n";
> #print join ("<br>", @allProductQuantities), "<br>";
> #print "ProductIDs = ", join ("<br>", @productIDs),  "<br>\n";
> 
> foreach $ID (@productIDs){
> #       print "Inside foreach $ID<br>";
>        $productQuantity = $query->param("Quantity_for_Product_$ID");
>        $dollarValue = $query->param("Dollar_Value_for_$ID");
>        if ($productQuantity){
>                print "Product $ID: ", "No of items = $productQuantity, ";
>                print $query -> hidden (-name => "Quantity_for_Product_$ID",
>                                           -default => "$productQuantity",
>                                          );
>                print "Total value  = \$", "$dollarValue\n";
>                print $query -> hidden (-name => "Dollar_Value_for_$ID",
>                                           -default => "$dollarValue",
>                                           );
> 
>                print $query -> br, "\n";
>        }
> }
> 
> print $query -> hr, "\n";
> print "<b>Total number of products ordered = ",
>        $query -> param ("Total_Quantity_of_Products_Ordered"), "<br></b>\n";
> print $query -> hidden (-name => "Total_Quantity_of_Products_Ordered",
>                        -default => ($query -> param
> ("Total_Quantity_of_Products_Ordered"))
>                                           );
> 
> print "\n<b>Total cost of products ordered = \$",
>        $query -> param("Total_Dollar_Amount_of_Products_Ordered"),
> "<br></b>\n";
> print $query -> hidden (-name => "Total_Dollar_Amount_of_Products_Ordered",
>                        -default => ($query -> param
> ("Total_Dollar_Amount_of_Products_Ordered"))
>                                           );
> 
> print "\n<b>Total sales tax = \$", $query -> param
> ("Total_Amount_of_Tax"), "<br></b>\n";
> print $query -> hidden (-name => "Total_Amount_of_Tax",
>                        -default => ($query -> param ("Total_Amount_of_Tax"))
>                                           );
> 
> print "\n<b>Total shipping cost = \$", $query -> param
> ("Total_Dollar_Amount_of_Shipping"), "<br></b>\n";
> print $query -> hidden (-name => "Total_Dollar_Amount_of_Shipping",
>                        -default => ($query -> param
> ("Total_Dollar_Amount_of_Shipping"))
>                                           );
> 
> print "\n<b>Total amount of sale = \$",$query -> param
> ("Total_Dollar_Amount_of_Sale"), "<br>\n";
> print $query -> hidden (-name => "Total_Dollar_Amount_of_Sale",
>                        -default => ($query -> param
> ("Total_Dollar_Amount_of_Sale"))
>                                           );
> print "<BR>\n";
> 
> if ($query -> param ("Check_or_Money_Order")){
>        print qq{You are paying by check or money order.\n};
>        print qq{Please print the order page and mail  it to the address
> given below.\n};
>        print qq{We will send your order within a working days after
> receiving payment in most cases.\n};
>        print $query -> hidden (-name => "Check_or_Money_Order",
>                        -default => ($query -> param ("Check_or_Money_Order"))
>                                           );
>        print "<BR>\n";
> }
> 
> if ($query -> param ("VISA")){
>        print qq{You are paying by VISA.\n};
>        print $query -> hidden (-name => "VISA",
>                        -default => ($query -> param ("VISA"))
>                                           );
>        print "<BR>\n";
> 
>        print qq{Your card number: },
> $query->param("Credit_Card_Number"), "<BR>\n";
>        print $query -> hidden (-name => "Credit_Card_Number",
>                        -default => ($query -> param ("Credit_Card_Number"))
>                                           );
>        print "<BR>\n";
> 
>        print qq{The expiration date is: },
> $query->param("Credit_Card_Expiration_Date"),
>                "<BR>\n";
>        print $query -> hidden (-name => "Credit_Card_Expiration_Date",
>                        -default => ($query -> param
> ("Credit_Card_Expiration_Date"))
>                                           );
>        print "<BR>\n";
> 
>        print qq{The name on the credit card is: },
>                $query->param("Credit_Card_Imprinted_with_Name_of"), "<BR>\n";
>        print qq{We will send your order within a working days in most
> cases.<BR>\n};
>        print $query -> hidden (-name => "Credit_Card_Imprinted_with_Name_of",
>                        -default => ($query -> param
> ("Credit_Card_Imprinted_with_Name_of"))
>                                           );
>        print "<BR>\n";
> }
> if ($query -> param ("MasterCard")){
>        print qq{You are paying by Mastercard.\n};
>        print $query -> hidden (-name => "MasterCard",
>                        -default => ($query -> param ("MasterCard"))
>                                           );
>        print "<BR>\n";
> 
>        print qq{Your card number: },
> $query->param("Credit_Card_Number"), "<BR>\n";
>        print $query -> hidden (-name => "Credit_Card_Number",
>                        -default => ($query -> param ("Credit_Card_Number"))
>                                           );
>        print "<BR>\n";
> 
>        print qq{The expiration date is: },
> $query->param("Credit_Card_Expiration_Date"),
>                "<BR>\n";
>        print $query -> hidden (-name => "Credit_Card_Expiration_Date",
>                        -default => ($query -> param
> ("Credit_Card_Expiration_Date"))
>                                           );
>        print $query -> hidden (-name => "Credit_Card_Expiration_Date",
>                        -default => ($query -> param
> ("Credit_Card_Expiration_Date"))
>                                           );
>        print "<BR>\n";
> 
>        print qq{The name on the credit card is: },
>                $query->param("Credit_Card_Imprinted_with_Name_of"), "<BR>\n";
>        print $query -> hidden (-name => "Credit_Card_Imprinted_with_Name_of",
>                        -default => ($query -> param
> ("Credit_Card_Imprinted_with_Name_of"))
>                                           );
>        print "<BR>\n";
> 
>        print qq{Your order will ship within 48 hours of receipt via priority
> mail, which typically delivers within 3 days.<BR>\n};
> }
> 
> $value = $query->param ("Questions");
> if ($value){
>        print qq{Questions: $value <BR>\n};
>        print $query -> hidden (-name => "Questions",
>                        -default => ($query -> param ("Questions"))
>                                           );
> }
> print "<BR>\n", $query->submit(-name=>'Submit My Order'); print
> $query->endform, "\n";
> 
> print $query -> hr, "\n";
> 
> print $query->end_html ();
> 
> =====end of form1.pl===



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to