1)I had created Access database and register it.
2)Then I had created html form with three fields name,
email and Submit button.
3)Copied example perl fiel from net(given
below)->changed DSN name->changed mdb file name
4)And mentioned this perl file path in action tag of
form
5)DBI and DBD are installed on my m/c.
When I click on Submit button, File download dialog
box comes.. with options like you want to open perl
file or save it.
If I keep Apache server running or not it doesn’t make
any difference. I would appreciate, if you suggest
solution for this problem.
Thanks in advanced.
Pallavi.
PERL FILE.
#!/usr/bin/perl
# Jean Lambert - 28 may 2000
# Last updated : 6 jan 2000
# Example for DBI and ODBC connection to MS Access
print "Content-type:text/html\n\n";
use CGI qw(:standard); # Must be used to get the
param() function
use DBI; # Must be used for connecting to databases
engine
$name = param("name"); # Gets the workOrder field from
the HTML form
$email = param("email"); # Gets the Email field from
the HTML form
$comment = param("comment"); # Gets the Comment field
from the HTML form
# This formats the incoming data from the comment text
zone
$comment =~ s/\n/ /g; # Replaces newlines with spaces
$comment =~ s/\r//g; # Replaces hard returns with
nothing
$comment =~ s/\cM//g; # Delete ^M's
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime();
$mon += 1; # Ajust the month to a 1 to 12 format
instead of a 0 to 11 format
$year += 1900; # $year is nb of years since 1900, so
add up to 1900
$currentDate = "$year/$mon/$mday $hour:$min:$sec";
#------------------------------------------------------------------------
# This section is for appending the data to the
database.
sub new_record {
# This function add a record to the db
my ($currentDate, $name, $email, $comment) = @_; #
Get arguments
my ($dbh, $sth, $sql, $rv);
$dbh = DBI->connect( q{DBI:ODBC:DataBase},
{RaiseError => 1,
PrintError => 1,
AutoCommit => 1} );
$sql = q{INSERT INTO FirstTable VALUES (?,?,?,?)};
$sth = $dbh->prepare( $sql );
$sth->bind_param( 4, $comment, DBI::SQL_LONGVARCHAR
); #Allows to transfer data to Access memo field (more
than 255 char)
$ rv =
$sth->execute($currentDate,$name,$email,$comment);
my $success = 1;
$success &&= $rv;
$dbh->disconnect;
return $success;
}
# This function appends the data to the db
if (new_record($currentDate,$name,$email,$comment)) {
#------------------------------------------------------------------------
# This section prints a thanks-for-being-so-nice
message
print <
Thank you $name for filling the comment.
J. Lambert
EndHTML
}
else {
print <
-- Erreur !
EndHTML
exit;
}
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/