Page 1 of 1

<textarea> and percentage character or pound sign

Posted: Sat Jul 31, 2010 9:46 am
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?

Re: <textarea> and percentage character or pound sign

Posted: Sat Jul 31, 2010 10:26 am
by jraede
It performs those functions automatically so that's not the problem.

Try adding "SecFilterEngine off" (without the quotes) to your .htaccess file.

Re: <textarea> and percentage character or pound sign

Posted: Sat Jul 31, 2010 6:38 pm
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.

Re: <textarea> and percentage character or pound sign

Posted: Mon Aug 30, 2010 5:49 pm
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...

Re: <textarea> and percentage character or pound sign

Posted: Tue Aug 31, 2010 1:48 am
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'.

Re: <textarea> and percentage character or pound sign

Posted: Tue Aug 31, 2010 7:25 am
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

Re: <textarea> and percentage character or pound sign

Posted: Sat Sep 04, 2010 9:54 am
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?

Re: <textarea> and percentage character or pound sign

Posted: Sat Sep 11, 2010 10:17 am
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.

Re: <textarea> and percentage character or pound sign

Posted: Sat Sep 11, 2010 11:00 am
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.