Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Sanitizing


Adam5000 - 11:03 pm on Oct 4, 2010 (gmt 0)


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>


Thread source:: http://www.webmasterworld.com/php/4211280.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com