1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Special Character in Username

Discussion in 'General PHP and MySQL Discussions' started by veemon, Oct 17, 2015.

  1. veemon

    veemon Member

    Hey there!
    I implented a new site with a login script I found in this forum and everything worked nicely, until someone with a special character (♥) tried to login.
    I absolutely can't seem to find the error here.
    The $username shows it correctly if I echo it and it's correctly displayed in the database as well.
    The problem seems to be when getting the $data.
    When dumping it I noticed that it would just return a false boolean when I tried logging in with the ♥ character.
    Thanks in advance for any help!

    Here is the script:
    PHP:
            $startTime microtime(true);
           
            require(
    '../library/XenForo/Autoloader.php');
            
    XenForo_Autoloader::getInstance()->setupAutoloader('../library');
           
            
    XenForo_Application::initialize('../library');
            
    XenForo_Application::set('page_start_time'$startTime);
           
            
    $username $_POST['username'];
            
    $password $_POST['password'];
           
            
    $db XenForo_Application::getDb();
           
            
    $data $db->fetchOne('
                SELECT
                    auth.data
                FROM xf_user_authenticate AS auth
                INNER JOIN xf_user AS user ON
                    (user.user_id = auth.user_id)
                WHERE user.username = ?
            '
    $username);
           
            
    $id $db->fetchOne('SELECT user_id FROM xf_user WHERE username = ?'$username);
           
            
    $auth XenForo_Authentication_Abstract::createDefault();
           
            
    $auth->setData($data);
           
            
    $check $auth->authenticate($username$password);
           
            
    var_dump($data);
            if(
    $check) {
                
    session_start();
               
                
    /*redirect('gamesite/protected/')*/;
            } else {
                
    /*redirect('gamesit/index.php?message=2')*/
            }
     

Share This Page