_______________________________________________________________________________________________________________________________________________________________________
Farhan
Khalid
This
____________________________________________________________________________________________________________________________________________________________________
makes
____________________________________________________________________________________________________________________________________________________________________
any
____________________________________________________________________________________________________________________________________________________________________
difference
____________________________________________________________________________________________________________________________________________________________________
to
____________________________________________________________________________________________________________________________________________________________________
the script
____________________________________________________________________________________________________________________________________________________________________
____________________________________________________________________________________________________________________________________________________________________
18:31:42, Wed Aug 6, 2008
####
____________________________________________________________________________________________________________________________________________________________________
Farhan
Khalid
This
makes
any
difference
to
the script
18:31:42, Wed Aug 6, 2008
_________________________________________________________________________________________________________________________________________________________________________________
##
##
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $query= new CGI;
my $filename= "testfile.txt";
my $value;
my $fname;
my $lname;
my $textarea;
my $delimiter_used="|";
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
my $year = 1900 + $yearOffset;
my $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$month] $dayOfMonth, $year";
sub Writing_to_file
{
my @input_to_file=@_;
open (DAT, ">>$filename") || die ("no file exists");
print DAT join($delimiter_used, @input_to_file), "\n";
close(DAT);
}
sub display_on_browser
{
open (DAT, $filename) || die ("no file exists");
my @data_in_the_file=;
close(DAT);
print "Content-type:text/html\n\n";
print "Guestbook";
for my $line (@data_in_the_file)
{
my @fields = split(/\Q|\E/gm, $line);
for my $field (@fields)
{
print "
$field";
}
print "
____________________________________________________________________________________________________________________________________________________________________";
}
print "Back to Guestbook
";
print "";
}
$fname=$query->param('name');
$lname=$query->param('name1');
$textarea=$query->param('comments');
if ($fname eq "")
{
print "Content-type:text/html\n\n";
print "Guestbook";
print "You have missed out your first name";
print "Back to Guestbook
";
print "";
}
elsif($lname eq "")
{
print "Content-type:text/html\n\n";
print "Guestbook";
print "You have missed out your last name";
print "Back to Guestbook
";
print "";}
elsif($textarea eq "")
{
print "Content-type:text/html\n\n";
print "Guestbook";
print "You have missed out your comments";
print "Back to Guestbook
";
print "";}
else
{
Writing_to_file($fname,$lname,$textarea,$theTime);
display_on_browser();
}