CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
help!!! - output into html

 



dandan
Deleted

Apr 4, 2000, 1:10 AM

Post #1 of 3 (582 views)
help!!! - output into html Can't Post

hi i need help!!!
how to get cgi to pront to exsiting html
i tryed:
print{FILE, ">>test.html"}
Content-type: text/html\n\n;
print >>EFO;
.....EFO
print "Location: $return\n\n";
So...what do i do?


darian
Deleted

Apr 4, 2000, 1:41 AM

Post #2 of 3 (582 views)
Re: help!!! - output into html [In reply to] Can't Post

First off please be more explicit in what you are looking for. The more info the easier it is to help.

Second to print out an html page you need to use this:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open(FILE, "test.html") or die("$!");
while (<FILE> ) {
print $_;
}
close(FILE);
</pre><HR></BLOCKQUOTE>

Now if you are looking to just add some lines to an existing file you do this:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

#!/usr/local/bin/perl
use CGI qw(:cgi);
use CGI::Carp qw(fatalsToBrowser);
$in = new CGI;
$text = $in->param('text');
open(FILE, ">>test.html") or die("$!);
print FILE "$text";
close(FILE);

print "Location: $return\n\n";</pre><HR></BLOCKQUOTE>

Don't use the

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

print "Content-type: text/html\n\n";</pre><HR></BLOCKQUOTE>

line above the
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

print "Location: $return\n\n";</pre><HR></BLOCKQUOTE>
line. This will simply print out that line replacing the $return with the url you specified. If you need to use this line after the header then call it in it's own sub.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

&go_url;
sub go_url {
print "Location: $return\n\n";
}</pre><HR></BLOCKQUOTE>


dandan
Deleted

Apr 4, 2000, 3:57 AM

Post #3 of 3 (582 views)
Re: help!!! - output into html [In reply to] Can't Post

dear Darian
thank u for helping
here is the cgi code it is a simple one i should latter do a different form , i wount to do this : results to html page on web
So i did this:
#!/usr/local/bin/perl

#variables that will be used later.
$guestbookreal = "/cgi-bin/guestbook.html";
$return = "http://www.kadin1.we-host.net/cgi-bin/guestbook.html";


push(@INC, "/cgi-bin");
require("cgi-lib.pl");
&ReadParse(*input);
#Determine the base price based on the system variable
if ($input{'system'} eq "486d66") {
#set 486 only variables
$computer_name = "486DX2-66";
$price = 1099;
$memory = 4;
$video = "VLB";
}
else {
#not a 486 must be pentium system
$computer_name = "Pentium";
$memory = 8;
$video = "PCI";
$cache = "256K Cache" ;
if ($input{'system'} eq "P100"){$price = 1799 ;$ptype = 100}
elsif ($input{'system'} eq "P75"){$price =1550 ;$ptype = 75}
elsif ($input{'system'} eq "P60"){$price = 1450;$ptype = 60}
}
#add extra price for monitors over 14inch

$monitor = $input{'monitor'};
if ($input{'monitor'} eq "17inch"){$price += 650 ;}
elsif ($input{'monitor'} eq "15inch"){$price +=200 ;}
#add multimedia system
if (defined($input{'sound'})) {
$price += 190;
$multimedia="MultiMedia System";
}

#add 14.4 modem price
if (defined($input{'modem'})) {
$price += 69;
$modem="14.4 modem";
}

#build a Web page from scratch
open(FILE, "test.html") or die("$!");
while (<FILE> ) {
print <<EFO;


<html>

<head>

<title>$test</title>

</head>

<body>

<h1 align=center> Austin Computer Center North <br>Austin Texas! </h1>

<center>


<table border=5>

<th colspan=2 align=center> <h2>

${computer_name} $ptype for only \$$price

</h2>

<tr><td> <ul>

<li>$memory megs of Ram

<li>$cache

<li>Enhanced IDE In/Out Controller

<li>$monitor NIL SVGA Monitor

<li>1 Meg $video SVGA Video Card

<li> $multimedia

</ul>

<td> <ul>

<li>1.44 Floppy Drive

<li>500+ meg Hard Drive

<li>Mouse

<li>Windows 95

<li> $modem

</ul>

<tr>

<td align=right colspan=2> <h2> 1 YEAR WARRANTY PARTS & LABOR! </h2>

<tr>

</table>

</center>

</body>

</html>

EOF
}

close(FILE);

the page is in cgi bin, should i trunsfer it to upper stage?
thanks again dana

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives