I'm using a html form to send data to a php file using $_POST. How can I validate password data without stripping any special characters. I'd like the users to be able to have the option to increase password strength while keeping my website secure from hackers.
W3Schools suggests the following function to validate $_POST data:
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
However when working with passwords it strips characters which can increase strength.
EDIT:
The reason I'd like to validate data is for the reasons mentioned in this answer: https://stackoverflow.com/a/8683832/4787260.