My data does not go to BD using Ionic and php

Asked

Viewed 154 times

1

I’m developing an Ionic app. When saving, the following message appears on the console:

http://localhost:8888/systems/systems_web/Ionic/vcApp/www/php/salvaEndereco.php 500 (Internal Server Error) Ionic.bundle.js:19346 POST

Follow my codes

angular controller:

angular.module('app.controllers', [])

.controller('loginCtrl', function($scope) {

})

.controller('enderecoCtrl', function ($scope, $http) {

    $scope.adicionarEndereco = function (endereco){
        $http.post("php/salvaEndereco.php", endereco).success(function (data){

        });
    }
})

php:

<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type,X-Prototype-Version,X-Requested-With');

include_once("con.php");

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);

$cep = $request['cep'];
$uf = $request['uf'];
$cidade = $request['cidade'];
$bairro = $request['bairro'];
$logradouro = $request['logradouro'];

$insert = "INSERT INTO cep VALUES(NULL, '$cep', '$uf', '$cidade', '$bairro', '$logradouro')";

mysqli_query($con, $insert);
?>
  • Got ini_set('display_errors', true); error_reporting(E_ALL); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); header('Access-Content-Control-Allow-Headers: Type,X-Prototype-Version,X-Requested-With'); include_once("con.php"); $data = file_get_contents("php://input"); $data = json_decode($data); $cep = $data->cep; $Uf = $data->Uf; $city = $data->city; $neighborhood = $date->neighborhood; $street = $date->#Xa;$street = "INSERT INTO cep VALUES(NULL, '$cep', '$Uf', '$city', '$neighborhood', '$logradouro')"; mysqli_query($con, $Insert);

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.