Database connection problem


#1

need help, trying to connect mysql database with ionic 1 project using codeigniter but getting this (Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource) error


#2

no-one here to help? great


#3

Hi,
can you be more specific about the issue? so that we could try to analyze


#4

//This is my code:

class Webservices extends CI_Controller {

public function __construct() {
	parent::__construct();
	date_default_timezone_set("Asia/Kolkata");
	
	$this->load->model('Model_webservice');
	
	
	
}

public function signup(){
$postdata = file_get_contents(“php://input”);
$request = json_decode($postdata,true);
print_r($request);

$checkuser=$this->Model_webservice->checkuser($request);
// print_r($checkuser);

if($checkuser>0){
   $res=  array( 'status'=>'failure','message'=> "Email Id Already exists");
}
else{
   $result = $this->Model_webservice->signup($request);
   
   if($result){
     $res= array( 'status'=>'success','message'=> "Registration Successfull",'user'=>$result);
   }
   else{
     $res= array( 'status'=>'failure','message'=> "Sorry Not Registered.Please try again");
   }
}


print json_encode($res);

}

public function signin(){
$postdata = file_get_contents(“php://input”);
$request = json_decode($postdata,true);
//print_r($request);
$result = $this->Model_webservice->signin($request);
if($result){
$finresult = array( ‘status’ => ‘success’,‘message’ =>‘Successfully Login’, ‘code’ => ‘success’,‘result’=>$result);
}else{
$finresult = array( ‘status’ => ‘failed’,‘message’ => ‘Unknown Credential , please try again!’, ‘code’ => ‘Login failed’);
}


#5

This is badly formatted PHP code, not an Ionic problem.

If you are getting a CORS error, you have to fix that one. Usually this means returning a header that is right now missing.


#6

Thank u for reply :slight_smile: