0

This is a function from Codeigniter, built inside application/modules/myrest/controllers/user.php

function user_registration_post()
    {   
        header('Content-type: application/json');
        $postdata = file_get_contents("php://input");
        $request = json_decode($postdata,true); 
        $otp = rand(1111,9999); 
        $result_mob = $this->Webservice_model->user_reg_mobile($request);
        if($result_mob!="")
        {
            $result_email = $this->Webservice_model->user_reg_email($request);
            if($result_email !="")
            {
                $num = rand(1111,9999);
                $em = substr($request['email'],0, 4);
                $referral_code = strtoupper($em) . $num;
                
                if($request['code'] !="")
                {
                    $referral = $this->Webservice_model->referral_code($request);
                    if($referral =="")
                    {
                        $result = array('status'=>'error','message' =>"Referral code does not exist.",'responsecode'=>'500','data'=>"");
                    }
                    else
                    {
                        $result_both = $this->Webservice_model->referral_code_registration($request,$otp,$referral_code,$referral);
                        if($result_both!="")
                        {   
                            $moblie = $result_both->mobile;
                            $message = "Your otp is" ." ".$otp;             
                            $resp = $this->send_sms($moblie,$message);
                            if($resp)
                            {
                                $result = array('status'=>'success','message' =>"Registration done",'responsecode'=>'200','data'=>$result_both);
                            }                   
                        }
                        else
                        {           
                            $result = array('status'=>'error','message' =>"Mobile number and email exist. hum first",'responsecode'=>'500','data'=>"");
                        }   
                    }   
                }   
                else
                {
                    $result_both = $this->Webservice_model->user_reg($request,$otp,$referral_code);
                    
                    if($result_both!="")
                    {   
                        $moblie = $result_both->mobile;
                        $message = "Your otp is" ." ".$otp;             
                        $resp = $this->send_sms($moblie,$message);
                        if($resp)
                        {
                            $result = array('status'=>'success','message' =>"Registration done",'responsecode'=>'200','data'=>$moblie);
                        }                   
                    }
                    else
                    {           
                        $result = array('status'=>'error','message' =>"Mobile number and email exist. hum ky h to",'responsecode'=>'500','data'=>$result_both);
                    }
                }           
            }   
            else
            {
                $result = array('status'=>'error','message' =>"Email id exist",'responsecode'=>'500','data'=>"");
            }   
        }   
        else
        {
            $result = array('status'=>'error','message' =>"Mobile Number exist yeh dusra waala hai",'responsecode'=>'500','data'=>"");
        }   
        
        $this->response($result);       
    }

$request = json_decode($postdata,true);

This $result showing null values, even when I'm passing some values while API calling.

I assume that I might have to put any url in second line, in file_get_contents("") method.

0 Answers0