main.pl #!/usr/bin/perl -w use CGI; use DBI; use Template; my $cgi = CGI->new(); my $html = Template->new; my $host = "sql2.freemysqlhosting.net"; my $usr = "sql2343290"; my $pwd = "qV5*gE2%"; my $dbname = "sql2343290"; my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { AutoCommit => 0, RaiseError => 1, }) or die $DBI::errstr; my $select_names = $dbh->prepare("select id, name from names"); $select_names->execute(); my $names = $select_names->fetchall_arrayref(); $dbh->disconnect; print "Content-type: text/html\n\n"; my $temp_html = < Untitled Document

content

======================================================
|
|content
|
-------------------------------------------------------

after submit relond only content in this div (box)

 

[% FOREACH name IN list %]

Name: [% name.1 %]

[% END %]


---------------------------------------------------------
|
| content
|
======================================================

content

START_HTML $html->process (\$temp_html, { list => $names}) or die $html->error; #### delete.pl #!/usr/bin/perl -w use CGI; use DBI; use JSON; use CGI qw(:standard); my $cgi = CGI->new(); my $host = "sql2.freemysqlhosting.net"; my $usr = "sql12345678"; my $pwd = "**********"; my $dbname = "sql12345678"; my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { AutoCommit => 0, RaiseError => 1, }) or die $DBI::errstr; $db_id = $cgi->param("dbid"); if (param('delete') eq 'delete') { my $delete = $dbh->prepare("delete from names where id =?"); $delete->execute($db_id); $delete->finish(); $success = "user deleted"; my $json = encode_json( { msg => $success } ); print $cgi->header( -type => 'application/json' ),$json; } $dbh->commit; $dbh->disconnect;