I have a very simple form, consisting of two files:
<form action="test.php" method="post">
<input type='text' name = 'name' value="ł ą ź ć ę ó" >
<input id='submit' type='submit' name = 'submit' value="SEND">
$name = $_POST['name'];
echo "<a href='http://myaddress/$name/'>NAME</a>"
"<a href='http://myaddress/l a ź ć e ó/'>NAME</a>"
%xx encoded form is percent-encoding or "URL encoding". You can produce it using the
rawurlencode function. That function takes the raw bytes of your string and turns them into percent encoded groups. The exact output therefore depends on what bytes exactly you feed in, meaning what encoding your text is in.
If you need "ź" to encode to
%BC, then it must be encoded in ISO-8859-2 (as you say). There are two ways to get that:
Ensure your form is submitted as ISO-8859-2 by adding an appropriate attribute:
If you don't submit in the encoding you need, then instead convert it on the server:
$name = iconv('UTF-8', 'ISO-8859-2', $_POST['name']);
rawurlencode($name) should result in