#!c:/Dwimperl/perl/bin/perl.exe # PERL MODULES WE WILL BE USING use CGI; use DBI; use DBD::mysql; # Config DB variables our $platform = "mysql"; our $database = "test"; our $host = "localhost"; our $port = "3306"; our $tablename = "addressbook"; our $user = "root"; our $pw = "password"; our $q = new CGI; # DATA SOURCE NAME $dsn = "dbi:mysql:$database:localhost:3306"; # PERL DBI CONNECT $connect = DBI->connect($dsn, $user, $pw); #Get the parameter from your html form. $lname=$q->param('lname'); $fname=$q->param('fname'); $phone=$q->param('phone'); $email=$q->param('email'); $address=$q->param('address'); $zip=$q->param('zip'); print $q->header; $sql="INSERT INTO test.addressbook(last_name,first_name) values('$lname','$fname')"; $sth = $connect->prepare($sql) or die "Can't prepare $sql: $connect->errstrn"; #pass sql query to database handle.. $rv = $sth->execute or die "can't execute the query: $sth->errstrn"; #execute your query if ($rv==1){ print "Record has been successfully updated !!!n"; }else{ print "Error!!while inserting recordn"; exit; }