I have two input text boxes. One named First Name and the other is named Last Name. How would I get it so that when I person typed in there whole name in the First Name by accident that it will remove the spaces between the name. So if they typed Mark Constant into the First Name fied it would come out as MarkConstant. Thanks in advance.
Jun 22, 2002, 3:14 AM
Veteran / Moderator (18441 posts)
Jun 22, 2002, 3:14 AM
Post #4 of 15
Views: 9333
Not as good as PHP..there is a function to remove front/end spaces..as well as all spaces in a variable, without having to use regex...heh heh
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Jun 22, 2002, 7:34 PM
Novice (11 posts)
Jun 22, 2002, 7:34 PM
Post #6 of 15
Views: 9300
I tried the s/\//g; but it still doesn't seem to do anything. Here is my parsing script. I am using the method GET if that makes a difference.
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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{nd1} =~ s/\s//g;
$FORM{nd2} =~ s/\s//g;
$input{$name} = $value;
}
}
This edit.cgi is called from a script called add.cgi.
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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{nd1} =~ s/\s//g;
$FORM{nd2} =~ s/\s//g;
$input{$name} = $value;
}
}
This edit.cgi is called from a script called add.cgi.
Jun 23, 2002, 10:41 AM
Administrator (9387 posts)
Jun 23, 2002, 10:41 AM
Post #8 of 15
Views: 9248
That's not going to be a problem in the traditional "buffer overflow" sense (a common c exploit), as perl dynamically grows scalars. CGI.pm has a POST_MAX option, but it defaults off so it's no safer. It's very hard to get a buffer overflow exploit in perl, as memory is managed for you.
Cheers,
Alex
--
Gossamer Threads Inc.
Cheers,
Alex
--
Gossamer Threads Inc.
Jun 25, 2002, 9:10 AM
Novice (11 posts)
Jun 25, 2002, 9:10 AM
Post #13 of 15
Views: 9202
I changed
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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{nd1} =~ s/\s//g;
$FORM{nd2} =~ s/\s//g;
$input{$name} = $value;
}
}
to
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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;
$input{$name} = $value;
$input{nd1} =~ s/\s+//g;
$input{nd2} =~ s/\s+//g;
}
}
So the only difference is that I used $input{nd1} instead of $FORM{nd1} and everything seemed to work after that. Thanks again for the tips.
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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{nd1} =~ s/\s//g;
$FORM{nd2} =~ s/\s//g;
$input{$name} = $value;
}
}
to
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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;
$input{$name} = $value;
$input{nd1} =~ s/\s+//g;
$input{nd2} =~ s/\s+//g;
}
}
So the only difference is that I used $input{nd1} instead of $FORM{nd1} and everything seemed to work after that. Thanks again for the tips.
Jun 25, 2002, 9:17 AM
Veteran (19537 posts)
Jun 25, 2002, 9:17 AM
Post #15 of 15
Views: 9163
Hehe I'll try that again.
You have those regexs within the foreach loop which means they will run on every loop, you don't want that :)
You will probably want an if block to check if the current loop matches your field.
You have those regexs within the foreach loop which means they will run on every loop, you don't want that :)
You will probably want an if block to check if the current loop matches your field.