Checking if an Username is already in use
mysql_query() returns false only when there is something wrong with your query and it fails to execute. Otherwise, the return value is a resource which evaluates to success. That is your code always echoes "Account Exists". Check for the number of rows the SELECT statement fetched to determine whether the user exists or not.

Your code is also not secure. It is vulnerable to SQL injection. I would highly recommend NOT using mysql_* family of PHP functions. They are deprecated as of PHP 5.5.0 and will be removed in future releases. Consider switching over to mysqli_* family of functions or better use parameterized queries with PDO.

PDO:

$conn = new PDO('mysql:host='.$dbhost.';dbname='.$dbname,
                 $dbusername,
                 $dbpassword);

$username = $_POST["username"];
$password = $_POST["password"];


//Query statement with placeholder
$query = "SELECT Username 
          FROM Userdata 
          WHERE Userdata.Username = ?";

//Put the parameters in an array
$params = array($username);

//Execute it
try {
    $stmt = $conn-&gt;prepare($query);
    $result = $stmt-&gt;execute($params);
} catch(PDOException $ex) {
    echo $ex-&gt;getMessage());
}

//Now Check for the row count
if($stmt-&gt;rowCount === 1) {
    echo "Account Exists";
} else {
    echo "Account does not exist";
}