#!/usr/local/bin/perl #Get the submitted data $content_length = $ENV{'CONTENT_LENGTH'}; #Read user data into script variable read (STDIN, $form_data, $content_length); $form_data =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack("C",hex($1))/eg; $form_data =~ s/\+/ /g; @fields = split (/&/, $form_data); #Init script variables with form data values #$form_name is the name of the form. #from the text fields... ($Pizza, $name) = split (/=/, $fields[0]); ($Pizza, $address) = split (/=/, $fields[1]); ($Pizza, $phone) = split (/=/, $fields[2]); ($Pizza, $pizzas) = split (/=/, $fields[3]); ($Pizza, $instructions) = split (/=/, $fields[4]); #from the radio button... ($Pizza, $size) = split (/=/, $fields[5]); #set up variables for the three check boxes. ($cheese, $pepperoni, $sausage) = (0, 0, 0); foreach $type (@fields) { if ($type =~ /cheese/i) { $cheese = 1; } if ($type =~ /pepperoni/i) { $pepperoni = 1; } elsif ($type =~ /sausage/i) { $sausage = 1; } } #Set toppings to be printed out if ($cheese == 1) {@topping[0] = Cheese;} if ($pepperoni == 1) {@topping[1] = Pepperoni;} if ($sausage == 1) {@topping[2] = Sausage;} #Set price if ($size =~ /small/i) {$price = 6.99;} if ($size =~ /medium/i) {$price = 9.99;} elsif ($size =~ /large/i) {$price = 12.99;} #Find Total $total = $price * $pizzas; #Send back to the user a confirmation print << "END_OF_REPLY"; Content-type: text/html
Thanks for Your Order!
Please check the following for accuracy.
Your Name: $name