Notice: Undefined variable: userid in

1

I'm running a code but it marks these errors:

  

Notice: Undefined variable: userid in   C: \ xampp \ htdocs \ Edu \ profile.php on line 69

     

Notice: Undefined variable: followerid in   C: \ xampp \ htdocs \ Edu \ profile.php on line 69

What I understand is that it happens when a variable is not defined, but in my case, I do have those variables defined! I share my code:

PHP

<?php
include('classes/DB.php');
include('login.php');

 $name="";
 $email="";
 $isFollowing = False;

 if (isset($_GET['email'])){


    if(DB::query('SELECT name, email FROM registroalumnos WHERE email=:email', array(':email'=>$_GET['email']))){

         $name = DB::query('SELECT name, email FROM registroalumnos WHERE email=:email', array(':email'=>$_GET['email']))[0]['name'];
         $email = DB::query('SELECT email FROM registroalumnos WHERE email=:email', array(':email'=>$_GET['email']))[0]['email'];
         $userid = DB::query('SELECT id FROM registroalumnos WHERE email=:email', array(':email'=>$_GET['email']))[0]['id'];
         $followerid = login::isLoggedIn();


                if (isset($_POST['follow'])) {

                    if($userid != $followerid){

                        if (!DB::query('SELECT follower_id FROM followers WHERE user_id=:userid, AND follower_id=:followerid', array(':userid'=>$userid, ':followerid'=>$followerid))){
                               DB::query('INSERT INTO followers VALUES (null, :userid, :followerid)', array(':userid'=>$userid, ':followerid'=>$followerid));
                        } else {
                                echo 'Ya lo sigues!';
                        }

                        $isFollowing = True;
                    }
                }


     if (isset($_POST['unfollow'])) {
                        if ($userid != $followerid) {
                                if (DB::query('SELECT follower_id FROM followers WHERE user_id=:userid AND follower_id=:followerid', array(':userid'=>$userid, ':followerid'=>$followerid))) {

                                        DB::query('DELETE FROM followers WHERE user_id=:userid AND follower_id=:followerid', array(':userid'=>$userid, ':followerid'=>$followerid));
                                }
                                $isFollowing = False;
                        }
                }
                if (DB::query('SELECT follower_id FROM followers WHERE user_id=:userid AND follower_id=:followerid', array(':userid'=>$userid, ':followerid'=>$followerid))) {
                        //echo 'Ya lo sigues!';
                        $isFollowing = True;
                }


    }else {
        die('Usuario no encontrado');
    }
 } 


?>

HTML (which is where the error marks me) apparently on the line: if ($userid != $followerid)

<form action="profile.php?email=<?php echo $email; ?>" method="post">
            <?php
        if ($userid != $followerid) {
                if ($isFollowing) {
                        echo '<input type="submit" name="unfollow" value="Dejar de seguir">';
                } else {
                        echo '<input type="submit" name="follow" value="Seguir">';
                }
        }
        ?>

</form>

And if you can observe, in my PHP, if the variables are defined.

    
asked by Antonio Alejos 06.04.2018 в 07:16
source

0 answers