[solved] returns false?
Posted: Fri Aug 17, 2007 12:09 pm
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
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
Code: Select all
<?
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.";
}
}?>Code: Select all
<?
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;
}
}?>Code: Select all
<?
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;
}
}?>