Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,139 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,086 people online right now. Registration is fast and FREE... Join Now!




Redirection of cgi script

 
Reply to this topicStart new topic

Redirection of cgi script

perluser
post 29 Aug, 2008 - 04:36 PM
Post #1


New D.I.C Head

*
Joined: 6 Aug, 2008
Posts: 8

I'm trying to redirect a perl script to an html but I dont know what Im doing wrong. The page is telling me Internet Explorer cannot display the webpage and in the address bar its showing the c12ex3.cgi instead of c12ex3b.html page. FYI:The question was purposely put in.

<!c12ex3a.html>
<HTML>
<HEAD><TITLE>Patton Industries</TITLE></HEAD>
<BODY BGCOLOR=#FFFFCC>
<H2>Bonus Calculator</H2>
<TABLE>
<TR> <TD>Salesperson name:</TD>
<TD><INPUT NAME=Salesperson SIZE=30></TD></TR>
<TR> <TD>Sales amount:</TD>
<TD><INPUT NAME=Sales SIZE=10></TD></TR>
<TR> <TD>Bonus rate:</TD>
<TD><INPUT NAME=Rate SIZE=10></TD></TR>
</TABLE>
<P><INPUT TYPE=submit VALUE=Submit> <INPUT TYPE=reset></P>
</BODY>
</HTML>

#!usr/bin/perl
#c12ex3.cgi - calculates a bonus amount and creates a dynamic Web page
#that contains form data and a bonus amount
use CGI qw(:standard);

#prevent Perl from creating undeclared variables
use strict;
#declare variables
my ($name, $sales, $rate, $bonus);

#assign values to variables
$name = param('Salesperson');
$sales = param('Sales');
$rate = param('Rate');

#remove leading and trailing spaces from name
$name =~ s/^ +//;
$name =~ s/ +$//;

#remove leading and trailing spaces from sales
$sales =~ s/^ +//;
$sales =~ s/ +$//;

#remove leading and trailing spaces from rate
$rate =~ s/^ +//;
$rate =~ s/ +$//;

#calculate bonus amount
$bonus = $sales * $rate;

#create Web page
if ($name ne "" or $sales ne "" or $rate ne "") {
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD><TITLE>Patton Industries</TITLE><BASEFONT SIZE=5></HEAD>\n";
print "<H1>Bonus Calculation</H1>\n";
print "<BODY>\n";
print "Salesperson: $name<br>\n";
printf "Your bonus is \$%.2f.<br><br>\n", $bonus;
printf "You entered a sales amount of \$%.2f and a \n", $sales;
printf "bonus rate of %.1f%%.<br>\n", $rate * 100;
print "</BODY>\n";
print "</HTML>\n";
}
else {
print "Location:
http://?.netfirms.com/c12ex3b.html\n\n";
}

<!c12ex3b.html>
<HTML>
<HEAD><TITLE>Patton Industries</TITLE></HEAD>
<BODY>
<H2>Please press your browser's Back button to return to the form.
Then complete all items.</H2>
</BODY></HTML>


User is offlineProfile CardPM

Go to the top of the page

perluser
post 3 Sep, 2008 - 10:48 AM
Post #2


New D.I.C Head

*
Joined: 6 Aug, 2008
Posts: 8

Solved!
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/21/08 12:21PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month