returns false?

Discussion in 'PHP' started by promotingspace.net, Aug 18, 2007.

  1. #1
    Hi
    my login is not working after a coded the hasbalance function and made some changes.
    Could you please check if one of the 3 functions is always returning false?
    thanks
    php:
    <?
    function hasbalance($username){
      $sql="SELECT lastpaid, newbalance FROM jf_users WHERE username='$username' ";
       $resultp=mysql_query($sql);
       $rp=mysql_fetch_array($resultp);
       $lastp=$rp['lastpaid'];
       $newb=$rp['newbalance'];
       $now=date("Y-m-d H:i:s");
       $lastp=strtotime($lastp);
       $now=strtotime($now);
       $seconds=$now-$lastp;
       $months=$seconds/60/60/24/30;
       $ii=1;
       $feesql="SELECT * FROM payment WHERE id='$ii' ";
       $rfee=mysql_query($feesql) or die(mysql_error()) ;
       $rrow=mysql_fetch_array($rfee);
       $mfee=$rrow['mfee'];
       $s_have=$mfee*$months;
       if ($s_have < $newb) { return true; }
       else{
       echo "Sorry, you don't have enough balance to access the site features.";
       }
    }?>
    PHP:

    php:
    <?
    function isloggedin(){
            $u=mysql_real_escape_string($_COOKIE['jfuser']);
            $p=mysql_real_escape_string($_COOKIE['jfp']);
           
            $l=mysql_fetch_array(mysql_query("select username,password from jf_users where lcase(username)='".strtolower($u)."' and banned='0'"));
            if(strtolower($l['username'])==strtolower($u) and md5($l['password'])==$p){
            if (hasbalance($u))     {
        return true;
               }
               else echo "Sorry, you don't have enough balance to access the site features.";
      }else{
                    return false;
            }
    }?>
    PHP:

    php:
    
    <?
    function isvaliduser($u,$p){
    
            $l=mysql_fetch_array(mysql_query("select username,password from jf_users where lcase(username)='".strtolower($u)."' and password='".$p."' and banned='0'"));
            if(strtolower($l['username'])==strtolower($u) and $l['password']==$p && $p!="" && $u!=""){
            if (hasbalance($u))     {
        return true;
               }
                    else return false;
      }else{
                    return false;
            }
    }?>
    PHP:

     
    promotingspace.net, Aug 18, 2007 IP
  2. promotingspace.net

    promotingspace.net Peon

    Messages:
    361
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    solved
    the problem was an extra md5
     
    promotingspace.net, Aug 18, 2007 IP