Get the id of the logged in user


#1

hello,
i want get the id of logged in user and insert it in my database mysql
this my controller code

app.controller("SugCtrl",function($scope,$stateParams,$http,$state,$ionicPopup){
    var url="http://localhost/ionic/";

    $scope.sugData={};

    $scope.addsuggestion=function(){
      var s=$scope.sugData.suggestion;
     // var userId= $this->ion_auth->get_user_id();

      if(s){

             str=url+"insertsugg.php?suggestion="+s;
              $http.get(str)

                   .success(function(response){

                  $ionicPopup.alert({
                  title:'Envoyer suggestion',
                  template:'votre suggestion est bien envoyée'
                });
               
            }).error(function(){

            $ionicPopup.alert({
                  title:'Envoyer suggestion',
                  template:'Problème d\'envoi de suggestion'
                });
            })

      
      }else{
        $ionicPopup.alert({
                  title:'Envoyer suggestion',
                  template:'Merci de remplir le champ suggestion'
                });
      }
      
};

});

my code php
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");




    include"config.php";

    $suggest=$_GET["suggestion"];
   // $password=$_GET["password"];

    $sql="insert into suggestions(suggestion)
          values('$suggest')
    ";
    
    $res=mysqli_query($conn,$sql);
    if($res){
      echo true;
    }else{
      echo false;
    }
?>