I'd suggest using sprintf as well:
PHP Code:
$query = sprintf("SELECT * FROM users WHERE username='%s'", mysql_real_escape_string($_POST['username']);
$query = mysql_query($query);
That tells PHP beforehand what the string should look like, thus preventing injections somewhat.
Also, don't throw strip_tags, htmlspecialchars and mysql_real_escape_string into the one clean function. Make two; one for sanitizing and one for returning. Sanitizing will apply to all data going into the database (just need mysql_real_escape_string), and returning for data being echoed back to the user (htmlspecialchars imo, no need to strip the tags, just display everything back). You'll find yourself using a load of server resources if you echo everything back using mysql_real_escape_string.