Thanks for the replies, gentlemen. Now I've pretty much mangled the code but it almost works. The only problem is that the insert statement is inserting a blank row each time with no data in each column. The insert code i'm using is:
my $sth_ins = $dbh->prepare("INSERT INTO users (firstname, lastname, s
+tate, country) VALUES (?, ?, ? ,?)") or die "Couldn't insert the data
+";
$sth_ins->execute($FORM{firstname}, $FORM{lastname}, $FORM{state}, $FO
+RM{country});
I was talking about this problem with a friend of mine who is vaguely familiar with Perl and he mentioned that $FORM{value} was the only way to retrieve the data from
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
Is there another way to do it or am I just overlooking something the way it is now?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.