Results 1 to 9 of 9

Thread: [RESOLVED] Check User Existence

Threaded View

  1. #1

    Thread Starter
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Resolved [RESOLVED] Check User Existence

    Hi guys,

    Problem's this: I can't work with sql in php...
    So, I was wondering if anyone could help me out with a simple(?) user existence script.

    DB: subscription
    Table: users
    Field: username

    I need something like a function which returns true or false
    This is the code that I already have, but it isn't working

    Code:
    <?
    	function querydb($query, $host, $user, $pass, $db)
    		{
    			$connid = @mysql_connect($host, $user, $pass) or die("Connection to the server failed");
    			@mysql_select_db($db) or die ("Connection to database failed");
    			$retval = @mysql_query($query) or die ("Query excecution failed");
    			return $retval;
    		}
    		
    	function checkuser($username)
    		{
    			$username = strtolower($username);
    			$q = "SELECT * FROM users WHERE username = '$username'";
    			$ret = querydb($q, 'localhost', 'root', '', 'subscription');
    			while ($row = mysql_fetch_assoc($ret)) {
    				$myret = $row["username"];
    			}
    			if ($myret != ''){
    				//echo "Username is unavailable";
    				echo $myret;
    			}
    			else{
    				//echo "Username is available";
    				echo $myret;
    			}
    		}
    ?>

    Thanks for any help
    Last edited by TheBigB; May 12th, 2007 at 02:13 PM.
    Delete it. They just clutter threads anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width