Running Perl script in the backend from Html

Discussion in 'Perl Misc' started by satish2112@gmail.com, Sep 11, 2007.

  1. Guest

    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?
     
    , Sep 11, 2007
    #1
    1. Advertising

  2. wrote:
    > 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');

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Sep 11, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,816
  2. Ted
    Replies:
    1
    Views:
    425
  3. Replies:
    2
    Views:
    108
  4. Replies:
    4
    Views:
    297
    ccc31807
    Jul 29, 2011
  5. Replies:
    1
    Views:
    140
Loading...

Share This Page