[Solved] php username that checks on database “username already taken” [duplicate]


Please use below code to fix your problem

<?php

    if(empty($_POST['username'])){
      $username_error = "Please Input Username";
    }else{
      if( 6 > mb_strlen($_POST['username']) || 20 < mb_strlen($_POST['username'])){
        $username_error = "username must be at least 6 characters.";
      }else{
          $username = $_POST['username'];
          $sql = "SELECT
                members.username
                FROM
                members
                WHERE username="". $username.""";
          $res = mysql_query($sql);
          if($res && mysql_num_rows($res) > 0){
            $username_exists = "Username is already taken.";
          }else{
            $username = $_POST['username'];
          }
      }     
    }

?

11

solved php username that checks on database “username already taken” [duplicate]