Currently, everything is functioning correctly. However, the issue arises when trying to initiate the progress bar while sending emails.
I have encountered difficulties implementing various examples of progress bars in CGI.
The documentation available does not provide a clear understanding of how to implement a progress bar in CGI.
If anyone could assist me with the code above, it would greatly benefit my learning and allow me to grasp how the progress bar operates within CGI. This knowledge can be applied to my future projects.
#!/usr/bin/perl -w
use lib '.';
use strict;
use warnings;
use DBI;
use CGI;
use MIME::Lite;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI();
my $host = "localhost";
my $usr = "root";
my $pwd = "";
my $dbname = "tbl_users";
my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, {
AutoCommit => 0,
RaiseError => 1,
}) or die $DBI::errstr;
my $sub = $q->param("sub");
my $msg = $q->param("msg");
my $success;
if ($sub) {
my $getemails = $dbh->prepare("SELECT DISTINCT EMAIL FROM USERS");
$getemails->execute();
my $dbemails = $getemails->fetchall_arrayref;
my $emails = join ',',map{$_->[0]}@$dbemails;
my $to = '';
my $from = '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="513f3e2334213d302811223825347f323e3c">[email protected]</a>';
my $subject = $sub;
my $message = "$msg";
my $MSG = MIME::Lite->new(
From => $from,
To => $to,
Bcc => $emails,
Subject => $subject,
Data => $message
);
$MSG->send;
$success = "mail was sent successfully";
}
$dbh->disconnect || die "$DBI::errstr\n";
print "Content-type: text/html\n\n";