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.
Help!
<html>
<head>
<title>Registration form</title>
</head>
<body>
<form action="test.php" method="post">
<input type="text" name="user_name">
<br>
<input type="text" name="psword">
<br>
<input type="submit" value="Submit">
</form>
<?php
if ($_POST["user_name"] || $_POST["psword"] contains \ or/ or*)
{
echo "Field contains at least one invalid character";
}
else
{
echo "All characters are valid";
}
?>
</body>
</head>