<textarea> and percentage character or pound sign

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dameunmate
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 2:15 am

<textarea> and percentage character or pound sign

Post by dameunmate »

Code: Select all

<form action='target.php' method= 'get' >
<textarea name='newdata' cols='100%' rows='5'></textarea> 
<input type='submit' value='Submit'> 
</form>
Most text I enter into the text area can be used by php in the target page without any problems. But if I type the characters % or £ in the text area I get following the error message in target.php:

Not Acceptable
An appropriate representation of the requested resource /empty.php could not be found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


...with % in the textarea the url reads target.php?newdata=%25 and with £ in the textarea the url reads target.php?newdata=%A3

I've looked at urlencode and htmlentities but how do I apply them to a text area before the form is submitted and the contents sent to the querystring?
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: <textarea> and percentage character or pound sign

Post by jraede »

It performs those functions automatically so that's not the problem.

Try adding "SecFilterEngine off" (without the quotes) to your .htaccess file.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: <textarea> and percentage character or pound sign

Post by superdezign »

dameunmate wrote:I've looked at urlencode and htmlentities but how do I apply them to a text area before the form is submitted and the contents sent to the querystring?
That'd be something that you'd do on the client-side (JavaScript, VBScript, etc.) or allow the server to handle. I'd try ~jraede's suggestion. It helps with some form difficulties in Apache.
dameunmate
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 2:15 am

Re: <textarea> and percentage character or pound sign

Post by dameunmate »

Thanks for the tips! I have no idea about .htaccess so I'm going to read up on it now. If it helps here's a link to my phpinfo(): http://piano-tuning.co.uk/info.php - somebody else said I should look at Apache modules, I wonder what they are? It's so strange I've never had a problem with % or £ symbols in the querystring before...
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: <textarea> and percentage character or pound sign

Post by Apollo »

Is there a reason why you use get instead of post to submit the form?
You may avoid URL encoding trouble altogether by using 'post' rather than 'get'.
dameunmate
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 2:15 am

Re: <textarea> and percentage character or pound sign

Post by dameunmate »

Yes I use GET because I'm still on a steep learning curve and I really need to see what goes into the querystring to understand my mistakes
dameunmate
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 2:15 am

Re: <textarea> and percentage character or pound sign

Post by dameunmate »

yes I note that if I use POST I don't get the same error. Is there a reason for this? And is it possible to have a percentage % or pound £ symbol in the querystring in a php document when using GET?
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: <textarea> and percentage character or pound sign

Post by Apollo »

dameunmate wrote:yes I note that if I use POST I don't get the same error. Is there a reason for this? And is it possible to have a percentage % or pound £ symbol in the querystring in a php document when using GET?
The input data is urlencoded when it's sent as a GET query (i.e. included in the URL). This does not happen when you use POST.

So when using GET, you have to urldecode the input before using it.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: <textarea> and percentage character or pound sign

Post by McInfo »

Apollo wrote:So when using GET, you have to urldecode the input before using it.
PHP Manual wrote:Warning

The superglobals $_GET and $_REQUEST are already decoded. Using urldecode() on an element in $_GET or $_REQUEST could have unexpected and dangerous results.
Post Reply