SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Perl and DBI Insert???
-
Dec 2, 2002, 16:21 #1
Perl and DBI Insert???
Hey there
I just figured out how to use a select statement to retrieve data from a table and display it on a webpage.
How would I setup a script that would take information received through and form and input it into a table???
Jake
-
Dec 3, 2002, 00:03 #2
- Join Date
- Nov 2002
- Location
- Moscow, Russia
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can use something like this:
Code:use CGI; use DBI; # creating a new CGI object my $cgi = new CGI; # creating a new DB handler object my $dsn = "DBI:mysql:db-name:db-host:db-port"; my $dbh = DBI->connect($dsn, db-user, db-pass) || die $DBI::errstr; my $sth = $dbh->prepare('insert into table-name set field1 = ?, field2 = ?, field3 = ?'); $sth->execute( $cgi->param('form-field1'), $cgi->param('form-field2'), $cgi->param('form-field3') ) || die $DBI::errstr; $sth->finish; $dbh->disconnect;
Last edited by eych; Dec 3, 2002 at 00:06.
Bookmarks