Reputation: 1187
What is the best way to encode text posted to a PHP script from an HTML form so that special characters, i.e. "#'@ etc are not modified in anyway. My thoughts were to uuencode the data with JavaScript at form submission and then base64_decode()
it in PHP, or escape the text with js then urldecode()
with PHP, or is there another way?
Upvotes: 2
Views: 4219
Reputation: 142
I know this is a very old question but this is what you maybe were looking for:
<form action="/cgi-bin/script.php" method="post" enctype="application/x-www-form-urlencoded">
<!-- Form elements go here -->
</form>
The weird thing is that the enctype="application/x-www-form-urlencoded" should be the default - but something happens when I don't use it.
Upvotes: 0
Reputation: 6142
You do that very easy by setting an appropriate codepage like UTF-8:
<form action="/cgi-bin/script.php" method="post" accept-charset="UTF-8">
<!-- Form elements go here -->
</form>
I would always try do do stuff without client-side scripting first, because of compatibility.
Upvotes: 1