Trying to check if username already exists in MySQL database using PHP

后端 未结 8 1916
无人共我
无人共我 2020-12-28 10:12

I\'ve looked at the many other posts that were similar to my issue and implemented their solutions (as far as I can tell) as exactly as I could. However, every time I execut

8条回答
  •  心在旅途
    2020-12-28 10:46

    TRY THIS ONE

     mysql_connect('localhost','dbuser','dbpass');
    
    $query = "SELECT username FROM Users WHERE username='".$username."'";
    mysql_select_db('dbname');
    
        $result=mysql_query($query);
    
       if (mysql_num_rows($query) != 0)
       {
         echo "Username already exists";
        }
    
        else
       {
         ...
        }
    

提交回复
热议问题