I own an online game where you have a status box. Which you can update it on how you're feeling. The problem I have had was that users were putting java script tags into messages and into status. So when another user came to their page, a pop up box would pop up saying haha or whatever they wanted.
I then stopped that by using
$status = mysql_real_escape_string($_POST['status']);
$foo = preg_replace('/[^a-z]/i', null, $status );
That has now stopped any JavaScript being ran but now when someone sends someone a message, it takes the spaces out so for the message "how are you " It will show "howareyou". Of course this is safe but users can't read messeges. Is there any other way from stopping script tags being inserted into the virable but still allow spaces?
I'm also real scared of someone hacking me with XSS. Because before, I was told a user could enter something in a message then when the other user opens it, it will send them there password.....