frank1 has asked for the wisdom of the Perl Monks concerning the following question:
I have some Question and really need help on this thing
but i really dont know where to start from
I want to submit such data via html at once using text area
---START---- |FULLNAME: JANE DEO |BINF : 492BBJJ |PRICE: 10 |COUNTRY: GR ---END---
---START---- |FULLNAME: JOHN DEO |BINF : K92BBJJ |PRICE: 24 |COUNTRY: AS ---END---
my main point is i want to be able to store multiple data to database instead of inserting 1 by 1
so i want to store each data where is START and END
#!/usr/bin/perl -w use DBI; use CGI qw/:standard/; my $CGI = CGI->new; my $host = "localhost"; my $dbname = ""; my $usr = ""; my $pwd = ''; my $dbh_usr = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { RaiseError => 1, }) or die $DBI::errstr; # $binf extracted from data where is |BINF : # $price extracted from data where is |PRICE: # $info this is the whole ---START---- and ---END--- my $upload = $CGI->param("data"); if ($upload) { my $update_info = $dbh_usr->prepare("INSERT INTO ITEMS(user, pid, basn +m, binf, info, status, price) VALUES(?,?,?,?,?,?,?)"); $update_info->execute('join123', '898', 'ion +o', $binf, $info, 'Active', $price); $update_info->finish; } $dbh_usr->commit; $dbh_usr->disconnect; print "Content-type: text/html\n\n"; print <<HTML; <!DOCTYPE html> <html> <head> </head> <body> <h1>The textarea</h1> <form method="POST"> <textarea name="data" rows="4" cols="50"></textarea> <br> <input type="submit" value="Submit"> </form> </body> </html> HTML
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extract data and store to db
by LanX (Saint) on Nov 01, 2022 at 23:37 UTC | |
by frank1 (Monk) on Nov 02, 2022 at 11:07 UTC | |
by LanX (Saint) on Nov 02, 2022 at 11:20 UTC |