hwritetofile.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 input data.

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

# Write the data.

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 form with a hidden field.
# When submitted, the value of the hidden field will be passed to the Perl script.

print "Data written to file.";
print "<br><form name = \"formData\" method=\"POST\" action =
\"http://oz.uc.edu/cgi-bin/cgiwrap/jonesbr/whatIsaid.pl\">";
print "<input type = \"hidden\" name = \"bearcatID\" value = \"$bearcatID\">";
print "Now see what I said!";
print "<input type=\"submit\" value=\"Go!\">";
print "</form>";

#   End the form.
print $query->endform;

 Back
 Home