| | |
# symbol in get statement
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 14
Reputation:
Solved Threads: 0
Hi All,
I am processing a form that includes address info. If the user fills out the form and (address2) has an apartment number that they enter like:
#1522
I have trouble later where I might contruct a link such as:
The link creates fine, but processing on the otherside where I am trying to get the data back stops after encountering the # sysmbol. The code I have to get the data from the link is:
The address2 field is empty as are all the fields that come after it in the process. Any ideas what to do to allow the # symbol?
Thanks.
I am processing a form that includes address info. If the user fills out the form and (address2) has an apartment number that they enter like:
#1522
I have trouble later where I might contruct a link such as:
PHP Syntax (Toggle Plain Text)
header("location: contact.php?address1=$address1&address2=$address2&city=$city&state=$state");
The link creates fine, but processing on the otherside where I am trying to get the data back stops after encountering the # sysmbol. The code I have to get the data from the link is:
PHP Syntax (Toggle Plain Text)
if(isset($_GET["address2"])) $address2 = $_GET["address2"]; else $address2 = "";
The address2 field is empty as are all the fields that come after it in the process. Any ideas what to do to allow the # symbol?
Thanks.
Last edited by pritaeas; Sep 30th, 2009 at 5:07 pm.
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Sep 2009
Posts: 14
Reputation:
Solved Threads: 0
My created url looks like this:
http://www.domain.com/contact.php?ad...=123%20Main%20 Street&address2=#1522&city=chicago
As you can see, the # is probably my problem.
http://www.domain.com/contact.php?ad...=123%20Main%20 Street&address2=#1522&city=chicago
As you can see, the # is probably my problem.
urlencode()
Look it up.
Look it up.
Google is your friend.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
The text after a # in a querystring is taken to be an anchor or bookmark. You should encode the data before passing it to a querystring.
Use urlencode and htmlentities:
//EDIT
sorry KK, you posted as I was typing
Use urlencode and htmlentities:
PHP Syntax (Toggle Plain Text)
$q_string = 'address1=' . urlencode($address1) . '&address2=' . urlencode($address2) . '&city=' . urlencode($city) . '&state=' . urlencode($state); header( 'Location: contact.php?' . htmlentities($q_string));
//EDIT
sorry KK, you posted as I was typing
Last edited by ardav; Sep 30th, 2009 at 5:22 pm.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
![]() |
Similar Threads
- Bison ! "start symbol 'grammar' does not derive any sentence" meaning? (C)
- Trouble when adding a library in borland C++(undefined symbol "fct_name" ...) (C++)
- Help with "cannot find symbol" error (Java)
- pointers help (C++)
- Boolean Algebra (C++)
- if then statement (C++)
- Combining multiple programs...activating under anb ift statement?? (C++)
- Object-Oriented Programming (C++)
- compiling problems (C++)
- C++ Syntax (C++)
Other Threads in the PHP Forum
- Previous Thread: random generated number integrated into a form
- Next Thread: Add images in the PDF file using PHP
| Thread Tools | Search this Thread |







