#!h:/xampp/perl/bin/perl -w # PERL MODULES WE WILL BE USING use DBI; use DBD::mysql; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use dbConnect; require "ap_messages_config.pl"; #PULL IN THE FILE THAT CREATES EACH H +TML RESPONSE PAGE #INCLUDES THE SUB 'STYLE' FOR CSS $q = new CGI; print $q->header(); my @values = split(/=/,$ENV{QUERY_STRING}); my $customer_get = $values[1]; my $customer_post = $q->param('customer_post'); my $num_buildings = ""; my $errors = ""; my @parameters = $q->param(); #THIS JUST STORES THE NAMES OF THE PARAM +ETERS. TO PRINT ITS VALUE, USE #param($parameters[0]) . "<br>\n"; ###################################################################### +########################################### ############################## BEGIN MAIN PROGRAM #################### +########################################### ###################################################################### +########################################### #style (); print $q->start_html(); if (($q->param('section_number')) < 2) { sectionOne($customer_get); } if (($q->param('section_number')) eq "2") { sectionTwo(); } if (($q->param('section_number')) eq "3") { sectionThree($customer_post); } if (($q->param('section_number')) eq "4") { sectionFour(); } print $q->end_html(); ###################################################################### +########################################### ############################## BEGIN MAIN PROGRAM #################### +########################################### ###################################################################### +########################################### ############################################## SUBROUTINES ########### +########################################### =pod sub javaScript() { # USE CGI 'start_html' TO ADD JAVASCRIPT TO HEADER print $q->start_html( -title=>'Enter AP Names', -script=> { -language => 'javascript', -src => '../scripts/hideDiv.js' } ); style (); } =cut ################################## HTML PAGE TO ASK USER NUMBER OF BUI +LDINGS ##################################### sub sectionOne() { print "Section One.<br>\n"; print "The value of \$customer_get is: $customer_get.<br>\n"; print "The value of \$customer_post is: $customer_post.<br>\n"; print "Enter the Number of Buildings:\n"; print "<form name=\"form1\" action=\"add_building_names.cgi\" method=\ +"POST\">\n"; print "<table style=\"border-collapse:separate;padding:0px;width:100px +;font-size:8pt\">\n"; print "<tr>\n"; print "<td><input type=\"text\" name=\"num_buildings\" size=\"5\"></td +>\n"; print "<td><input type=\"submit\" name=\"submit_num_buildings\" value= +\"Update\"></td>\n"; print "</tr>\n"; print "<input type=\"hidden\" name=\"section_number\" value=\"2\">\n"; print "<input type=\"hidden\" name=\"customer_post\" value=\"" . $_[0] + . "\">\n"; print "</form>\n"; print "</table>"; } #print param('num_buildings') . "<br>\n"; #THIS WORKS #print param($parameters[0]) . "<br>\n"; #THIS WORKS TOO. ################################### HTML PAGE TO RENDER INPUT BOXES FO +R BUILDING NAMES ############################ sub sectionTwo() { print "Section Two.<br>\n"; print "The value of \$customer_get is: $customer_get.<br>\n"; print "The value of \$customer_post is: $customer_post.<br>\n"; #print "The length of \@parameters is: $#parameters.\n"; print "<table>\n"; print "<form name=\"building_names\" method=\"POST\" action=\"add_buil +ding_names.cgi\">\n"; my $num_buildings = $q->param('num_buildings'); for ($i=1; $i<=$num_buildings; $i++) { print "<tr>\n"; print "<td>Building: " . $i . "</td>\n<td><input type=\"text\" name=\" +building_" . $i . "\"></td>\n"; print "</tr>\n"; } print "<tr>\n"; print "<td>"; print "<input type=\"submit\" name=\"submit_building_names\" value=\"U +pdate\">\n"; print "</td>\n"; print "</tr>\n"; print "<input type=\"hidden\" name=\"section_number\" value=\"3\">\n"; print "</form>\n"; print "</table>\n"; } ###################################### PRINT AND CONFIRM BUILDING NAME +S ########################################3 sub sectionThree() { print "$_[0]<br>\n"; print "Section Three.<br>\n"; print "The value of \$customer_get is: $customer_get.<br>\n"; print "The value of \$customer_post is: $customer_post.<br>\n"; my $customer = $_[0]; print "The value of \$customer (passed in to sub) is: $customer.<br>\n +"; #Store the building names to variables for ($i = 0; $i<$#parameters; $i++) { #print $q->param($parameters[$i]) . "<br>\n"; if (($parameters[$i]) =~ /^building/) { my @buildings = push (@buildings,($q->param($parameters[$i]))); } } $j = scalar (@buildings); my @building_nums; for ($k = 1; $k<=$j; $k++) { push (@building_nums,$k); } print "<form name=\"submit_bldg_names\" method=\"POST\" action=\"add_b +uilding_names.cgi\">\n"; print "<table>\n"; print "<tr>\n"; print "<td>You entered the following building names. If they are corr +ect, select 'Submit' to add them to the database for customer $customer</td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td>"; print "<input type=\"submit\" name=\"add_bldgs_database\" value=\"Subm +it\">"; print "</td>\n"; print "</tr>\n"; for ($i = 0; $i<=$#buildings; $i++) { print "<tr>\n"; print "<td>"; print "Building $building_nums[$i]: $buildings[$i]"; print "<input type=\"hidden\" name=\"building_" . $i . "\" value=\"" . + $buildings[$i] . "\">"; print "</td>\n"; print "</tr>\n"; } print "<input type=\"hidden\" name=\"section_number\" value=\"4\">\n"; print "</table>\n"; print "</form>"; } ######################## ADD BUILDING NAMES TO THE DATABASE TABLE #### +#################################### sub sectionFour() { } ###################################################################### +####################################
In reply to Re^2: CGI 'start_html' not printing opening <body> or <html>
by spickles
in thread CGI 'start_html' not printing opening <body> or <html>
by spickles
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |