Hey! there,
I am currently working on a database project which needs user registration. The problem is that the username must be unique and I thought of this code and wrote it!

<?php if ( isset($uname) ): ?>
<?php
$result = mysql_query( "SELECT * FROM alumni");
while ( $row = mysql_fetch_array($result) )

{if ($uname == $row[uname]) {$uv = '';} else {$uv = 1;}}
?>

But, the problem with this snippet is that, when I exucute, it only checks if it is the same as the last added username and exits. So, I land up having more than one similar username's.

I later tried the following code, and ended having the same problem

$sql = "SELECT id from users where uname=$uname";
$result = mysql_query($sql);

if(mysql_num_rows($result)) {
# the username is taken
}
else {
# the username is not taken
}

Christian



------------------
Krishna