Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Building a Pizza: Completing the Order

June 14, 1999

sub complete_order()
 #checkout order
 { print $cgiobject->header;
   print $cgiobject->
		start_html(-title=>'Thank you from 
				    Build-a-Pizza',
			-bgcolor=>'white');
   $invoice= "<H2>Thank you for your pizza order!</H2>".
             "<HR>Deliveries should arrive in 30-45 minutes. ".
             "Pickup orders please arrive in about 20 minutes.<BR>".
             "The following order has been sent to the kitchen:<BR>";
   
   if ($deliver eq "deliver")
    { $invoice.="<B>Delivery</B> " }
   else
    { $invoice.="<B>Pickup</B> " }
   $invoice.="Order for: $name<br>";
   if ($deliver eq "deliver")
    { $invoice.="Delivery to: $address<br>" }
   $invoice.="Order Description: ".
   		"<br>A <B>$size</B> ".
		"pizza with the ".
		"following toppings:<br>";
   @allToppings=$cgiobject->param("order_toppings");
   $invoice.="<B>".join(",",@allToppings)."</B>";
   $invoice.="<BR>TOTAL DUE: ".sprintf("%.2f",&calcTotal());
   print $invoice;
   
  ##here would be code to send invoice kitchen
  ##such as by way of email
  
  }

When the user clicks "Finish Order" we move to the virtual checkout, as represented by the complete_order subroutine. This routine essentially constructs an invoice, assigned to $invoice, containing the information gathered from the submitted form fields. Once constructed, the invoice is output to the visitor's browser and might look something like:

Of course, the complete_order subroutine as shown only outputs the invoice to the customer's browser -- ideally the invoice should also be sent to the pizza kitchen! One possibility would be to add some Perl code which e-mails the invoice to a special e-mail address, always monitored at the pizza parlor. We've left out this code for now because there is no single "right" way to send an e-mail message from a Perl program -- it depends on the operating system being served from and its configuration. Episode #9 of the Perl FAQ addresses the question of sending an email message from within Perl. In our example, whatever the mechanics, we would want to send the value of $invoice as the body of the message.

Building a Pizza: Calculating Cost
The Perl You Need to Know
Building a Pizza: Updating the Order


Up to => Home / Authoring / Languages / Perl / PerlfortheWeb




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers