-1

1 .here is class for follow

class Follow extends User {
protected $pdo;

function __construct($pdo){
    $this->pdo = $pdo;
}
public function checkFollow($followerID, $user_id){
    $stmt = $this->pdo->prepare("SELECT * FROM `follow` WHERE `sender` = :user_id AND `receiver` = :followerID ");
    $stmt->bindParam(":user_id", $user_id, PDO::PARAM_INT);
    $stmt->bindParam(":followerID", $followerID, PDO::PARAM_INT);
    $stmt->execute();
    return $stmt->fetch(PDO::FETCH_ASSOC);
}

public function followBtn($profileID, $user_id){
    $data =$this->checkFollow($profileID, $user_id);
    if ($this->loggedIn()===true) {

        if ($profileID != $user_id) {
            if ($data['receiver'] == $profileID) {
                //following btn
                echo "<button class='f-btn following-btn follow-btn' data-follow='".$profileID."'>Following</button>";
            }else{
                //follow btn
                echo "<button class='f-btn following-btn follow-btn' data-follow='".$profileID."'><i class='fa fa-user-plus'></i>Follow</button>";

            }
        }else{
            //edit button
                        echo "<button class='f-btn' onclick=location.href='profileEdit.php'>Edit</button>";

        }
    }else{
        echo "<button class='f-btn' onclick=location.href='index.php'><i class='fa fa-user-plus'></i>Follow</button>";
    }
}

}

2 . here is my code in html to call for the button if user not logged in

 <body>
   <div class="edit-button">
        <span>
            <?php $getFromF->followBtn($profileId, $user_id); ?>
        </span>
    </div>
  </body>

And it show these error Notice: Undefined variable: getFromF in C:\xampp\htdocs\profile.php


Aoudesh01
  • 189
  • 2
  • 2
  • 12
  • 1
    You have to instantiate the class. Your variable is undefined. – elixenide Jun 24 '18 at 04:34
  • 2
    Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – elixenide Jun 24 '18 at 04:34

1 Answers1

0

It is telling you that you never defined $getFromF, and I don't see you doing that in the code that you posted. You need to do:

$getFromF = new Follow;

This will instantiate your class.

Victoria Ruiz
  • 4,913
  • 3
  • 23
  • 40