D
David Mills
First of all hello to the group
I'm relativly new to perl, so if this is a stupid question, I'll accept my
due flaming.
I've written a small script to take user information and insert it into a
database, before creating an account for the user (this is obviously for
internal use only, and has the relevant .htaccess to prevent unorthorised
use).
The problem is that when the form is submitted, I get 0 at the end of each
value field (and by this I mean a hex 0 in the field, I've checked this
with a hex editor).
My question is how to remove these zeros, since they muck up the user
creation and the insertion into the database.
Google has shown up nothing relating to this
I've quoted part of the script below which shows these symptomes
Thanks in advance for your time
David Mills
#!/usr/bin/perl -w
use DBI;
print "Content-type: text/html\n\n";
#get info from form, lifted from http://www.cgi101.com, great site
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
print "$buffer\n";
print "\n";
@pairs = split(/\n/, $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;
$FORM{$name} =~ s/\0//eg;
print "$name = $FORM{$name}t<br>";#Puts a 0 between the variable and the t
}
I'm relativly new to perl, so if this is a stupid question, I'll accept my
due flaming.
I've written a small script to take user information and insert it into a
database, before creating an account for the user (this is obviously for
internal use only, and has the relevant .htaccess to prevent unorthorised
use).
The problem is that when the form is submitted, I get 0 at the end of each
value field (and by this I mean a hex 0 in the field, I've checked this
with a hex editor).
My question is how to remove these zeros, since they muck up the user
creation and the insertion into the database.
Google has shown up nothing relating to this
I've quoted part of the script below which shows these symptomes
Thanks in advance for your time
David Mills
#!/usr/bin/perl -w
use DBI;
print "Content-type: text/html\n\n";
#get info from form, lifted from http://www.cgi101.com, great site
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
print "$buffer\n";
print "\n";
@pairs = split(/\n/, $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;
$FORM{$name} =~ s/\0//eg;
print "$name = $FORM{$name}t<br>";#Puts a 0 between the variable and the t
}