Ajax Post php class not loading problems?

Hi my problem ajax post after php extends class not loading. commfuct not found. There is no problem sending normal (Not using ajax) form.

page.php User UI

include_once("comment.class.php");
$new =new yorum();
$new->commentform($id,$cat);//for example

comment.php Ajax post page

inlcude_once("comment.class.php"); 
$new= new comment(); 
if(iseet($_POST)) 
{ 
$cek= $new->yorumkontrol("sa","[email protected]",7,"12sdeaege","bu bir yorum"); 
if(isset($cek["hata"])) 
{ 
echo $cek["hata"]; 
} 
} 
?>

Class.php Php Class file load function

class dahilet
{
function autoload($gelen) 
    { 
        $dy=__DIR__."/".$gelen.".sinif.php"; 
        if(file_exists($dy)) 
        { 
            include_once($dy); 
        } 
        else 
        { 
             
            die("$gelen not found."); 
        } 
    }
}
$dosyaknt=new dahilet();
spl_autoload_register(array($dosyaknt,'autoload'));

comment.class.php comment class index Comment form function
Comment form control function
Comment add database function
commfuct class index
Comment category control function
Comment bot control function
Comment gravatar control function
Comment google recaptcha control function

include_once("class.php");
$dh= new dahilet(); 
$dh->autoload("db"); 
class comment extends  commfunct 
    { 
    function yorumkontrol($a,$b,$c,$d,$e) 
    { 
    $na= self::konumsor($a,$b);
return $na;//for example
    } 
    
    } 
    class commfunct extends baglan 
    { 
      function konumsor($a,$b) 
      { 
      $sql="select * from linksistem where id=:idal,cid=:cidal order by sira asc limit 1"; 
       $sor=$db->prepare($sql); 
       $sor->execute(array("idal"=>$a,"cidal"=>$b)) 
       if(isset($sor->errorInfo()[2])) 
        { 
         if($sor->rowCount()>0) 
         { return false;} 
        else {return true;} 
        } 
       else{return false;} 
      } 
    } 
    ?>

Upvotes: 3

Views: 446

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72299

You extend the class commfunct. Here

class comment extends commfunct

But this commfunct class code is below this line and that's why commfunct class not found error is coming

Solution:-

Put your commfunct class code before extends line and you will good to go

Upvotes: 1

Related Questions