Hello i need some help with a script i am working on i have a mailserver and all users accounts are stored in a MySQL database.
I need to have a perl script that will take the user input and run the following database commands.
INSERT INTO domains (domain) VALUES ('example.com') ;
INSERT INTO users (email, password) VALUES ('sales@example .com', ENCRYPT('passwo rd'));
this is what i have so far
#!/usr/bin/perl -w
use strict;
use warnings FATAL => 'all';
use CGI;
use CGI::Carp qw(fatalsToBrow ser);
use DBI;
use DBD::mysql;
my $cgi = CGI->new;
print $cgi->header, $cgi->start_html;
my $domains = $cgi->param('domains ');
my $email = $cgi->param('email') ;
my $pasword = $cgi->param('passwor d');
my $database = "mail";
my $host = "localhost" ;
my $user = "user";
my $pw = "password";
my $dsn = "dbi:mysql:$dat abase:localhost :3306";
my $dbh = DBI->connect($dsn , $user, $pw,
{ RaiseError => 1 })
or die "unable to connect:$DBI::e rrstr\n";
my $query = "INSERT INTO domain (domain) VALUES (?,?)";
my $sth = $dbh->prepare($query );
$sth->execute($domai ns, $email);
# additional processing as needed ...
print $cgi->end_html;
any help is greatly apretiated
I need to have a perl script that will take the user input and run the following database commands.
INSERT INTO domains (domain) VALUES ('example.com') ;
INSERT INTO users (email, password) VALUES ('sales@example .com', ENCRYPT('passwo rd'));
this is what i have so far
#!/usr/bin/perl -w
use strict;
use warnings FATAL => 'all';
use CGI;
use CGI::Carp qw(fatalsToBrow ser);
use DBI;
use DBD::mysql;
my $cgi = CGI->new;
print $cgi->header, $cgi->start_html;
my $domains = $cgi->param('domains ');
my $email = $cgi->param('email') ;
my $pasword = $cgi->param('passwor d');
my $database = "mail";
my $host = "localhost" ;
my $user = "user";
my $pw = "password";
my $dsn = "dbi:mysql:$dat abase:localhost :3306";
my $dbh = DBI->connect($dsn , $user, $pw,
{ RaiseError => 1 })
or die "unable to connect:$DBI::e rrstr\n";
my $query = "INSERT INTO domain (domain) VALUES (?,?)";
my $sth = $dbh->prepare($query );
$sth->execute($domai ns, $email);
# additional processing as needed ...
print $cgi->end_html;
any help is greatly apretiated