Error in ionic project - signup error

Guys I downloaded a github project named “Ionic-Shopping-Cart” and there is a signup page. In that signup page it is checking whether an account is already created for the given credentials. In their video it is working correctly. But my browser shows an error as below.

TypeError: Cannot read property ‘created’ of undefined

This is because in my signup controller there is this if condition checking whether an account is already created.

if($scope.response.created==“1”){
$scope.title=“Account Created!”;
$scope.template=“Your account has been successfully created!”;

This is the controller code

.controller(‘signupCtrl’, function($scope,$http,$ionicPopup,$state,$ionicHistory) {

$scope.signup=function(data){

  	var link = 'http://www.yourwebsite.com/foodkart/signup.php';
  	$http.post(link, {n : data.name, un : data.username, ps : data.password , ph: data.phone , add : data.address , pin : data.pincode })
  	.then(function (res){	
  		$scope.response = res.data.result; 
  		if($scope.response.created=="1"){
  			$scope.title="Account Created!";
  			$scope.template="Your account has been successfully created!";
  			
  			//no back option
  			$ionicHistory.nextViewOptions({
  				disableAnimate: true,
  				disableBack: true
  			});
  			$state.go('login', {}, {location: "replace", reload: true});
  		
  		}else if($scope.response.exists=="1"){
  			$scope.title="Email Already exists";
  			$scope.template="Please click forgot password if necessary";
  		
  		}else{
  			$scope.title="Failed";
  			$scope.template="Contact Our Technical Team";
  		}
  		
  		var alertPopup = $ionicPopup.alert({
  				title: $scope.title,
  				template: $scope.template
  		});
  		
  		
  	});

}
})

This is my PHP code!

<?php header("Access-Control-Allow-Origin: *");

//http://stackoverflow.com/questions/18382740/cors-not-working-php
if (isset(_SERVER['HTTP_ORIGIN'])) { header("Access-Control-Allow-Origin: {_SERVER[‘HTTP_ORIGIN’]}");
header(‘Access-Control-Allow-Credentials: true’);
header(‘Access-Control-Max-Age: 86400’); // cache for 1 day
}

// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
        header("Access-Control-Allow-Methods: GET, POST, OPTIONS");         
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
        header("Access-Control-Allow-Headers:        {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
    exit(0);
}

$mysql_host = “localhost”;
$mysql_database = “xpressrentals”;
$mysql_user = “root”;
$mysql_password = “”;

// Create connection
$conn = new mysqli($mysql_host, $mysql_user, $mysql_password,$mysql_database);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

 //http://stackoverflow.com/questions/15485354/angular-http-post-to-php-and-undefined
$postdata = file_get_contents("php://input");

if (isset($postdata)) {
$request = json_decode($postdata);
$fname = $request->fname;
$lname = $request->lname;
$email = $request->email;
$password = $request->password;

  //if ($fname != "") {
  	//echo "Server returns: " . $fname;
        
        $sql = "INSERT INTO testingsignup (First_Name,Last_name,Email,Password) VALUES ('$fname','$lname','$email','$password')";
        
        if ($conn->query($sql) === TRUE) {
            echo "Sign Up Success!";
        } else {
            echo "Error: " . $sql . "<br>" . $conn->error;
            }
        $conn->close();
        
        
  //}
  //else {
  	//echo "Empty username parameter!";
  //}

}
else {
echo “Not called properly with username parameter!”;
}

?>

Waiting for a quick response for this problem. Thank you :slight_smile: