I'm not real familiar with the pgsql commands having never worked with them, but I imagine they're pretty similiar.
For one, you could do a:
SELECT COUNT(*) FROM dialup WHERE username='$usrnme'
and if the result is > 0 , you have an existing user by that name
You could also do use your existing query and and use the pg_numrows function like this:
if ($pg_numrows($query) > 0){
echo "you have an existing user";
} else {
echo "everything looks good";
}
There's probably some other ways to do it too...