Problem passing $_GET variable

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
iG9
Forum Commoner
Posts: 38
Joined: Fri Jul 18, 2008 2:11 pm

Problem passing $_GET variable

Post by iG9 »

So I'm processing a registration form, and if there's a problem I'm passing back what they entered so they don't have to retype it. so the URL looks like ...register.php?variable1=value1&variable2=value2 and so on. The problem comes when the user puts a '#' in their address. when it gets passed back it and all the variables after it get ignored. I think they're seen as a comment. So for example

Code: Select all

register.php?emailEntered=test@test.com&password=1&fnameEntered=John&lnameEntered=Smith&addr1Entered=100%201st%20St%20#3&addr2Entered=&cityEntered=Beverly Hills&stateEntered=CA&zipEntered=90210
is only being seen as

Code: Select all

register.php?emailEntered=test@test.com&password=1&fnameEntered=John&lnameEntered=Smith&addr1Entered=100%201st%20St%20#
by the page and the later fields aren't repopulating even though I see them in the URL. Any ideas how to pass back the # safely? Thanks.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Problem passing $_GET variable

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
iG9
Forum Commoner
Posts: 38
Joined: Fri Jul 18, 2008 2:11 pm

Re: Problem passing $_GET variable

Post by iG9 »

Thanks man I'll give it a try.
iG9
Forum Commoner
Posts: 38
Joined: Fri Jul 18, 2008 2:11 pm

Re: Problem passing $_GET variable

Post by iG9 »

Got it working. I used urlencode() on the processing page and

Code: Select all

parse_str(urldecode($_SERVER['QUERY_STRING']));
on the registration page. Then I had to change the logic from hanging on

Code: Select all

$_GET['variable']
to just

Code: Select all

$variable
The parse_str() man page had a comment to the effect that it would do an urldecode automatically but I didn't find that to be the case. Anyway thanks.
Post Reply