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

Error logging in. The username or password does not match

Discussion in 'PHP' started by abosirage, Apr 19, 2012.

  1. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    hi everybody
    here I am again with new problem because I am sure will get solution, I get very wonderful script for logging uploaded in my site http://islamicbank.ly/test/cars/fass/ as test it work for registration & write to database & send email with confirm code & confirm registration but when I try to login I am facing with this massage:
    Error logging in. The username or password does not match
    I attached files used in my case
    login.php
    membersite_config.php
    fg_membersite.php

    here is my login page
    HTML:
    <?PHP
    require_once("./include/membersite_config.php");
    
    if(isset($_POST['submitted']))
    {
       if($fgmembersite->Login())
       {
            $fgmembersite->RedirectToURL("login-home.php");
       }
    }
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
          <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
          <title>Login</title>
          <link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css" />
          <script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
    </head>
    <body>
    
    <!-- Form Code Start -->
    <div id='fg_membersite'>
    <form id='login' action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
    <fieldset >
    <legend>Login</legend>
    
    <input type='hidden' name='submitted' id='submitted' value='1'/>
    
    <div class='short_explanation'>* required fields</div>
    
    <div><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span></div>
    <div class='container'>
        <label for='username' >UserName*:</label><br/>
        <input type='text' name='username' id='username' value='<?php echo $fgmembersite->SafeDisplay('username') ?>' maxlength="50" /><br/>
        <span id='login_username_errorloc' class='error'></span>
    </div>
    <div class='container'>
        <label for='password' >Password*:</label><br/>
        <input type='password' name='password' id='password' maxlength="50" /><br/>
        <span id='login_password_errorloc' class='error'></span>
    </div>
    
    <div class='container'>
        <input type='submit' name='Submit' value='Submit' />
    </div>
    <div class='short_explanation'><a href='reset-pwd-req.php'>Forgot Password?</a></div>
    </fieldset>
    </form>
    <!-- client-side Form Validations:
    Uses the excellent form validation script from JavaScript-coder.com-->
    
    <script type='text/javascript'>
    // <![CDATA[
    
        var frmvalidator  = new Validator("login");
        frmvalidator.EnableOnPageErrorDisplay();
        frmvalidator.EnableMsgsTogether();
    
        frmvalidator.addValidation("username","req","Please provide your username");
        
        frmvalidator.addValidation("password","req","Please provide the password");
    
    // ]]>
    </script>
    </div>
    <!--
    Form Code End (see html-form-guide.com for more info.)
    -->
    
    </body>
    
    
    
    & this is my membersite_config.php

    HTML:
    <?PHP
    require_once("./include/fg_membersite.php");
    
    $fgmembersite = new FGMembersite();
    $fgmembersite->SetWebsiteName('موقع الصيرفة الاسلامية');
    $fgmembersite->SetAdminEmail('webd@islamicbank.ly');
    
    $fgmembersite->InitDB(/*hostname*/'localhost',
                          /*username*/'islamicb_123',
                          /*password*/'123',
                          /*database name*/'islamicb_car',
                          /*table name*/'login');
    
    $fgmembersite->SetRandomKey('qSRcVS6DrTzrPvr');
    
    ?>
    
    
    & this the part concerning in my fg_membersite.php page
    HTML:
    function GetLoginSessionVar()
        {
            $retvar = md5($this->rand_key);
            $retvar = 'usr_'.substr($retvar,0,10);
            return $retvar;
        }
        
        function CheckLoginInDB($username,$password)
        {
            if(!$this->DBLogin())
            {
                $this->HandleError("Database login failed!");
                return false;
            }          
            $username = $this->SanitizeForSQL($username);
            $pwdmd5 = md5($password);
            $qry = "Select name, email from $this->tablename where username='$username' and password='$pwdmd5' and confirmcode='y'";
           
            $result = mysql_query($qry,$this->connection);
            
            if(!$result || mysql_num_rows($result) <= 0)
            {
                $this->HandleError("Error logging in. The username or password does not match");
                return false;
            }
            
            $row = mysql_fetch_assoc($result);
            
            
            $_SESSION['name_of_user']  = $row['name'];
            $_SESSION['email_of_user'] = $row['email'];
            
            return true;
        }
    
    
    
    badly need for your help

    please help me
     
  2. smohd

    smohd New Member

    Joined:
    Aug 21, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Zanzibar
    So looks like the query returns 0 result,
    Lets start looking at your code:
    First are you sure that this condition is true for your user:
    Code:
    confirmcode='y'
    .
    Also did you use md5 to encrypt the password in registration?
     

Share This Page