I am trying to create a webpage on my site that takes input from a form (firstname,lastname) and process this input via a PERL CGI script and write that input to a file.
I would also like the page after script runs to display a message stating it successfully completed with links to get back to the homepage.
I am pretty sure my HTML page is correct when referencing the script so I will just post my perl script below.
Thanks in advance.
#!/usr/bin/perl
use strict; use warnings;
use CGI::Carp qw('fatalsToBrowser'); # send errors to the browser, not to the logfile
use CGI;
print header "Content-Type: text/html\n\n";
print start_html ("Receive Form Post");
my $datestring = localtime();
my $fname = param('firstname');
my $lname = param('lastname');
open (TESTFILE, '>>c:\inetpub\wwwroot\logfiles\bwrigsbee.txt') or die;
print TESTFILE "This file has been successfully edited on $datestring\n";
print TESTFILE "by $fname $lname\n";
close (TESTFILE);
print end_html;
HTML Form that is in the page that calls the script:
<form action="logwrite.pl" method="POST">
<table style="width:400px" border=1px border=solid border=black>
<tr>
<td>First name: <input type="text" name="firstname"></td>
</tr>
<tr>
<td>Last name: <input type="text" name="lastname"></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
Debug info from browser---> Undefined subroutine &main::param called at C:\studentwebusers\CIS33715\logwrite.pl line 11.
<form action=''Also, the content-type is important. Is the request even getting to the script? Also, check your permissions