# Detect if username exsists

**URL:** <https://forum.kirupa.com/t/detect-if-username-exsists/213379>\
**Category:** programming\
**Created:** [January 19, 2007, 2:42am UTC](https://forum.kirupa.com/t/detect-if-username-exsists/213379 "2007-01-19T02:42:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![james182](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@james182](https://forum.kirupa.com/u/james182)\
**Post date:** [January 19, 2007, 2:42am UTC](https://forum.kirupa.com/t/detect-if-username-exsists/213379/1 "2007-01-19T02:42:34Z")

</div>

Im trying to see if a username is already taken.

```php

$query = mysql_query("SELECT * FROM members_tbl WHERE username = ' ".$_POST['username']." '");//Edit the query to fit your needs
                        $result = mysql_num_rows($query);
                        
                        if($result[0] === ($username)) {
                            echo "The username you have chosen is available"; //Does not exist!
                        }else{
                            echo "The username you have chosen already exists!"; //It is there
                        }

```

Whats wrong with my code?
