Do you currently filter or verify user input at all?
Javascript code will not be executed unless it is "within" tags such as these:
Code:
<script type="text/javascript"> .. </script>
<script> .. </script>
<script [other attributes ..]> .. </script>
I have found that the easiest way to prevent against this is to just strip all HTML/markup tags from a given string. The easiest way to do this is to use the PHP function "strip_tags()", which removes all tags from the supplied arguement.
With the function you can also specify tags that you do not want to strip, such as "text formatting" HTML tags.
Example:
PHP Code:
<?php
..
$userInput = '<b>Hey!!</b> <i>Look, this shouldn\'t be here!!</i> <script> alert(\'XSS Hole!!\'); </script>';
$cleanedInput = strip_tags($userInput); // Would take *all* tags out of string.
$cleanedInput = strip_tags($userInput, '<b><i>'); // Would take *all* tags out of string except for the <b> and <i> tag(s).
..
?>
Hopefully that is a sufficient answer for you.. Let me know if you need something else or what not.