Home: Perl Programming Help: Intermediate:
Ampersand in Form Submissions



gregarios
stranger

Apr 7, 2002, 12:44 AM


Views: 1193
Ampersand in Form Submissions

I have a standard form script. How can I have it behave correctly when someone types in text that has ampersand and equals characters in it? Currently, the recipient, and other form fields are split by & then split by = to get the data; is there another way?


kidd
User

Apr 7, 2002, 10:58 AM


Views: 1192
Re: [gregarios] Ampersand in Form Submissions

 You could use JavaScript to change the = and & characters to something else and then inside your script change them back...

Just an idea...

"So you want to be a cowboy
Well you know it's more than just a ride
Guess you got to know the real thing
If you want to know the other side
Ain't nobody riding shotgun
In this world tonight"


gregarios
stranger

Apr 7, 2002, 11:08 AM


Views: 1191
Re: [kidd] Ampersand in Form Submissions

Good Idea, but I'm looking for something more reliable. I do have an idea that might work, but I need another answer to help it along.

I'm thinking of having one or both of two things happen. I could put an extra & in front of and at the end of each form field entry and then have it split on && instead of just &, and &= instead of just =. That would require redoing an incredible amount of html on several of my sites though, and some sites that aren't even mine! (I'm hosting the form cgi for those sites)

Another way would be to have the script only split it on an & that has no space directly after it, and on an = that has no space directly before it. I think that would eliminate at least 90% of the problem. However, I don't know how to accomplish this in the split function itself.

Can anyone show me some code that will accomplish this? :-)


yapp
User

Apr 8, 2002, 6:51 AM


Views: 1188
Re: [gregarios] Ampersand in Form Submissions

SOrry if I completely miss your point here, but aren't & and = characters encoded to %HEX signs right away by your browser? (HTTP specs)

Using a default module like CGI.pm makes it even easier to parse CGI QUERY_STRING input:


Code
 use CGI(); 
my $cgi = new CGI();my $value = $cgi->param('keyname');



-- Hope it helps

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


gregarios
stranger

Apr 8, 2002, 9:34 AM


Views: 1184
Re: [yapp] Ampersand in Form Submissions

Doh!

Your right. I was converting it before spitting it. Thanks. ;-)