Helpful Information
 
 
Category: HTML FORM
HTML Form -> PHP Special Characters

Hello. I'm trying to set up a user registration form, part of which contains a password field. I'd like the user to be able to have special characters in their password such as "[email protected]#$%&*){"...etc

I'm having trouble transferring the characters from the HTML form to the PHP page through a POST. For example, if I were to echo $_POST['password'] for an input of "abc#123", the output (unexpectedly) would only be "abc". The # seems to truncate at that point.


How could I send the password with the special characters escaped or at least intact?


Thanks!

Try using htmlentities() (http://us.php.net/manual/en/function.htmlentities.php).

Dan

Try using htmlentities() (http://us.php.net/manual/en/function.htmlentities.php).

Dan

Should I use that function on the PHP receiving end, sort of like this: $_POST['password'] = htmlentities($_POST['password']);?


Thanks for your help.

$password = mb_convert_encoding($_POST['password'], 'HTML-ENTITIES', "UTF-8");