I'm trying to sterilize my PHP code and I'm exploring options. The trim and other functions are good and I plan to use those too, and another idea I've got is to use an if / else statement to exclude certain characters.
What I've got so far is below.
<form action="test.php" method="post">
<input type="text" name="user_name">
<input type="text" name="psword">
<input type="submit" value="Submit">
if ($_POST["user_name"] || $_POST["psword"] contains \ or/ or*)
echo "Field contains at least one invalid character";
echo "All characters are valid";