i really gave you two different options there.
assume your variable with the user input again is $forminput.
one option is:
$forminput = htmlspecialchars($forminput);
that would take special characters and turn things like < into < & into & etc. it would also effect html. if they used <b>text</b>, it wont be bold on your output but it would actually show the tags.
the other option i gave was this:
$forminput = preg_replace("'<script[>]?>.?</script>'si", "", $forminput);
that will only affect javascript, and it would actually remove all script tags along with their code
so if someone put
<script language="javascript">
window.location = "http://www.mysite.com";
</script>
it would remove ALL of that javascript and leave the rest of their post untouched.