I am continuously getting error Undefined index in PHP while trying to login or sign up from my android app. I tried changing the PHP version but it didn't solve the problem. Here is the error I get in error_log :
[28-Aug-2017 15:15:33 America/Denver] PHP Notice:  Undefined index: full_name in /home2/heratarm/public_html/socialnetwork-api/Classes/user.php on line 33
[28-Aug-2017 15:15:33 America/Denver] PHP Notice:  Undefined index: username in /home2/heratarm/public_html/socialnetwork-api/Classes/user.php on line 34
[28-Aug-2017 15:15:33 America/Denver] PHP Notice:  Undefined index: email in /home2/heratarm/public_html/socialnetwork-api/Classes/user.php on line 35
[28-Aug-2017 15:15:33 America/Denver] PHP Notice:  Undefined index: password in /home2/heratarm/public_html/socialnetwork-api/Classes/user.php on line 36
[28-Aug-2017 15:15:57 America/Denver] PHP Notice:  Undefined index: username in /home2/heratarm/public_html/socialnetwork-api/Classes/user.php on line 12
[28-Aug-2017 15:15:57 America/Denver] PHP Notice:  Undefined index: password in /home2/heratarm/public_html/socialnetwork-api/Classes/user.php on line 13
And Here are my PHP codes:
class user
{
public function login()
{
    $data = [];
    require $_SERVER['DOCUMENT_ROOT'].'/socialnetwork-api/Config/db.php';
    $DB = new DB();$db=$DB->connection;
    $username =htmlentities($_POST['username'],ENT_QUOTES,"UTF-8");
    $password =htmlentities($_POST['password'],ENT_QUOTES,"UTF-8");
    $sql = "SELECT * FROM `tbl_users` WHERE `username`='$username' AND `password`='$password'";
    $result = $db->query($sql);
    $result = $result->fetch();
    if($result != null)
    {
        $data["result"]=$result['id'];
    }
    else
    {
        $data["result"]="0";
    }
    echo json_encode($data);
}
public function signup()
{
    $data = [];
    require $_SERVER['DOCUMENT_ROOT'].'/socialnetwork-api/Config/db.php';
    $DB = new DB();$db=$DB->connection;
    $fullname = htmlentities($_POST['full_name'],ENT_QUOTES,"UTF-8");
    $username = htmlentities($_POST['username'],ENT_QUOTES,"UTF-8");
    $email = $_POST['email'];
    $password = htmlentities($_POST['password'],ENT_QUOTES,"UTF-8");
    $sql = "SELECT * FROM `tbl_users` WHERE `username`='$username'";
    $result = $db->query($sql);
    $result = $result->fetch();
    if($result != null)
    {
        $data["result"] = "username";
    }
    else
    {
        $sql = "SELECT * FROM `tbl_users` WHERE `email`='$email'";
        $result = $db->query($sql);
        $result = $result->fetch();
        if($result != null)
        {
            $data["result"] = "email";
        }
        else
        {
            $sql = "INSERT INTO `tbl_users` (`full_name`,`username`,`email`,`password`) VALUES ('$fullname','$username','$email','$password')";
            $result = $db->prepare($sql);
            $result = $result->execute();
            if($result)
            {
                $data["result"]="1";
            }
            else
            {
                $data["result"]="0";
            }
        }
    }
    echo json_encode($data);
}
I hope someone helps me because I am not familiar with PHP so much and I need this for my project in University.
 
    