Running Perl script in the backend from Html

S

satish2112

Following is my HTML template:

<html>
<head>
<title>Web page</title>
</head>
<body>
<form method="post" action="script.pl">
<p><textarea cols="20" rows="20" name="field"></textarea></
p>
<p><input type="submit" value="update" ></p>
</form>
</body>
</html>

And the Perl Script script.pl is:

#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use DBI;

my $query = new CGI();
my $Value = $query->param('field');

my $dbh = DBI->connect('server address', 'username','password');
my $sth = $dbh->prepare("UPDATE tablename SET columnname = '$Value'
where condition;");
$sth->execute();
$sth->finish();
$dbh->disconnect;


if i click on the submit button, another webpage is opened and the
perl script is executed.
is there any way so that the perl script runs in the backend? ( so
that another webpage doesnt pop-up). how can i modify the above html
code in order to run the perl script in the backend?
 
G

Gunnar Hjalmarsson

Following is my HTML template:

<html>
<head>
<title>Web page</title>
</head>
<body>
<form method="post" action="script.pl">
<p><textarea cols="20" rows="20" name="field"></textarea></
p>
<p><input type="submit" value="update" ></p>
</form>
</body>
</html>

And the Perl Script script.pl is:

#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use DBI;

my $query = new CGI();
my $Value = $query->param('field');

my $dbh = DBI->connect('server address', 'username','password');
my $sth = $dbh->prepare("UPDATE tablename SET columnname = '$Value'
where condition;");
$sth->execute();
$sth->finish();
$dbh->disconnect;


if i click on the submit button, another webpage is opened and the
perl script is executed.
is there any way so that the perl script runs in the backend? ( so
that another webpage doesnt pop-up). how can i modify the above html
code in order to run the perl script in the backend?

print $query->header(-status=>'204 No Content');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top