Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.