Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hello All.

Firstly I wish all Indians A very Happy 73rd Independence Day.

Secondly, I had a query.

I have a querystring parameter named fcmid. The mobile client sends this id to me at time of logging in in to the system. I have created a login class to be able to put this value in the K_TBL_USERS. My login class code is as follows:
Code: Select all
<?php
require_once( '../couch/auth/auth.php' );
require_once( '../couch/auth/user.php' );
require_once( '../couch/auth/PasswordHash.php' );
class loginClass{

   
   function get_users_id($params,$params2){
      global $DB;
      $userid='0';///No password Delivered,
      if($params2!=''){
         $user = new KUser( $params );
         $userid=$user->id;
      }
      return $userid;
   }   
      //////////////////////////////////////////////   
   function get_users_info($rtty,$sysPwd,$myPwd,$fcmid){
      global $DB;
      /////////////////////////////////////////////
      
      if($fcmid==''){
         $hast='2';///No FCM ID
         return $hast;
         exit;
      }
      if($sysPwd!=$myPwd){
         $hast='3';///Wrong Password Entered
         return $hast;
         exit;
      }
      
      /////////////////////////////////////////////
      if($sysPwd==$myPwd){
         $n='20';
         $hast=bin2hex($this->getName($n));
         /////////////////////////////////////////////
         $sql ="UPDATE ".K_TBL_USERS." SET 
         hashToken ='".$hast."',
         fcmId ='".$fcmid."'
         WHERE
         id='".$DB->sanitize( $rtty )."'";

         if($DB->_query( $sql )){
            $sql_pgid =$DB->_query("SELECT cp.id as page_id FROM `couch_pages` cp INNER JOIN couch_users cu ON cu.id='".$DB->sanitize($rtty)."' and cp.page_name = cu.name WHERE template_id = 3");
            $sql_deviceid ="Update couch_data_text set value = '".$fcmid."' where page_id = '".$sql_pgid['page_id']."' and field_id = 13";
            $res_deviceid = $DB->_query($sql_deviceid);
               return $hast;
         }
      }else{
         $hast='4';///Unknown Error
         return $hast;
      }
   }   

      //////////////////////////////////////////////   
   function getName($n) {
      $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
      $randomString = '';
    
      for ($i = 0; $i < $n; $i++) {
         $index = rand(0, strlen($characters) - 1);
         $randomString .= $characters[$index];
      }
    
      return $randomString;
   }

}
?>


This works and inserts the id into the K_USERS_TBL.

But i also need the id in a editable region named as ipt_emp_registration_ids. This is required to send FCM Push notifications to mobile phones.

In the code above I have a few queries using which I am trying to insert the value from the querystring in to the editable region. The queries are in the
if($DB->_query( $sql )){
...
}

block.

What I am trying to do:
1. I am using
Code: Select all
$sql_pgid =$DB->_query("SELECT cp.id as page_id FROM `couch_pages` cp INNER JOIN couch_users cu ON cu.id='".$DB->sanitize($rtty)."' and cp.page_name = cu.name WHERE template_id = 3");

query to find the page_id of the user from the users/index.php template.

2. Then I am having a second query for update as:
Code: Select all
$sql_deviceid ="Update couch_data_text set value = '".$fcmid."' where page_id = '".$sql_pgid['page_id']."' and field_id = 13";

where i am trying to pass the page_id from the $sql_pgid.

3. And then executing the query by:
Code: Select all
$res_deviceid = $DB->_query($sql_deviceid);


All goes well and i get the desired output also. But the FCM Id is not added to the users/index.ph template. (The template is numbered 3).

How can I add the FCM Id to the ipt_emp_registration_ids to the users/index.php. Please help.

Regards,
GenXCdoers (Aashish)
Image
where innovation meets technology
:?:
Image
where innovation meets technology
2 posts Page 1 of 1