Search code examples
phphtmlurlencodeurldecode

Using urlencode() in form


I need to send special characters (like polish characters) using form. I figured out i need to use urlencode and urldecode. How to use it when sending form?

The code of form is

<form id="form1" action="add.php" method="POST" accept-charset="utf-8">
  Description: <input type=text name="title" maxlenght=150/><br/>
  Link: <input type=text name="link"/><br/>
<input type=submit value="Send"/>

Solution

  • You do not need to use them at all.

    Submitting a form will cause the browser to encode characters automatically.

    Since you are using PHP, $_POST will be populated with decoded characters automatically.


    If you are having character encoding issues where the characters are being encoded or decoded incorrectly, then see UTF-8 all the way through.