Jump to content

Check Username DOESNT WORK


pudge1

Recommended Posts

So I am creating a sign up script and part of the script has a function that checks if a username exists but everytime I try it, it shows that the username is already in use when it isn't... the database is empty.

 

  function Check_Username($username)
   {
     $user = 'nintendo_note';
     $pass = 'zeno118';
     $dbname = 'nintendo_note';

     $connection = mysql_connect('localhost',$user,$pass);

     mysql_select_db($dbname, $connection);

     $query="select Username from Users";
     $result=mysql_query($query);

      while($row=mysql_fetch_array($result))
       {
         if($username == $row['Username'])
          {
           return False;
          }
         else
          {
          }
       }
   }

 

and the actual use:

 

  if(!Check_Username(md5($_POST['username'])))
   {
    echo "Sorry username is already taken. Please choose another.";
    include_once('right.php');
    exit;
   }

 

I tried changing a lot of things and moving things around but nothing seems to work. I have also gone over the code many times. The e-mail section is coded the exact same way but for some reason it always thinks the e-mail is never taken.

Link to comment
https://forums.phpfreaks.com/topic/209746-check-username-doesnt-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.