Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Could anyone give me a sample code or direct me to a page where i could get a step by step code on how to write data directly to an mysql database after filling up an HTML form? I appreciate the help alot.

Replies are listed 'Best First'.
Re: writing to a mysql database
by btrott (Parson) on Jun 22, 2000 at 00:40 UTC
    There are some database tutorials in the Tutorials section. The main things you need to do are:
    • Install DBI and DBD::MySQL
    • open a database handle:
      my $dbh = DBI->connect(...);
    • prepare the SQL statement:
      my $sth = $dbh->prepare_cached(...);
    • execute and finish the statement:
      $sth->execute; $sth->finish;
    There's nothing Perl-specific about this. Do you know SQL? Here's a tutorial.

    You should also read the MySQL docs and the DBI docs.

    Oh, and you'll need to get the data from the HTML form... but I assume you're using CGI.pm, so that's not an issue.

Re: writing to a mysql database
by KM (Priest) on Jun 22, 2000 at 00:41 UTC
    Look at the POD for DBI.pm, or the book 'Writing the Perl DBI' published by ORA.

    Cheers,
    KM