writetofile.pl source

#!/usr/local/bin/perl
 
#    Use the CGI.pm library
use CGI;
 
# Make a new CGI object.
$query = new CGI;
 

#   Write out the content-type header followed by a blank line.

print $query->header;

#   Write the HEAD section, including the title.

print $query->start_html("Write to a file");

# Get the values of the two fields from the form.

$bearcatID = $query->param('bearcatID');
$say = $query->param('say');
 

# Write the data out to a file.

open(PAGE, ">>../$bearcatID.html");
print PAGE "<HTML><HEAD><TITLE>What I said</TITLE></HEAD>";
print PAGE "What I said: $say";
print PAGE "</body></html>";
close(PAGE);
chmod (0755, "../$bearcatID.html");

# Make a confirmation, and a dynamic link.

print "Data written to file.";
print "<br><a href =
\"http://oz.uc.edu/cgi-bin/cgiwrap/jonesbr/whatIsaid.pl?bearcatID=$bearcatID\">Now see
what I said!</a>";

#   End the html.
print $query->end_html;
 

 Back
 Home