SitePoint Sponsor |
|
User Tag List
Results 1 to 1 of 1
Thread: User Registration thru PHP
-
Aug 16, 2000, 19:49 #1
- Join Date
- Jul 2000
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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
Bookmarks