first up, you didn't need to post ALL that code. Here's the crux of the matter
$username = $HTTP_GET_VARS['username'];
$listquery = "select * from users where username='$username'";
//and you need this
echo "***$username***<br>\n***$listquery***<br>\n";
so, is username what you expect. if so, then that's not your problem.
if you run the query manually is it what you expect? copy and paste the query from the browser.
Use standard programming debugging techniques to identify your problem. You've stated that you think it is an HTTP problem when infact you don't know which line of code is letting you down.