#!/usr/bin/perl # ################################################################# # # Project: CGI-Programming # # Filename: addme.cgi # # Version: 1.0 # # Autor: Akadia AG, Martin Zahn 26.12.1999 # # Purpose: Shows how to implement a simple form to # add two numbers # # ################################################################# use strict; # enforce variable declarations and quoting use CGI qw(:standard); # load CGI module use CGI::Carp qw(fatalsToBrowser carpout); # Error Messages to Browser print header(), start_html("Add Me"); print ("\n"); print h1("Add Me"); # If Form already exists in browser ... if(param()) { my $n1 = param('field1'); my $n2 = param('field2'); my $n3 = $n2 + $n1; print p("$n1 + $n2 = $n3\n"); } # ... or create the Form else { print hr(), start_form(); print p("First Number:", textfield("field1")); print p("Second Number:", textfield("field2")); print p(submit("add"), reset("clear")); print end_form(), hr(); } print (""); print ("

Show source

"); print end_html();