Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. XMLHttpRequest cannot load http://www.ramosdainformatica.com.br/food/apinhac.php. Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
  2. app_controller.js:20 []
  3. app_controller.js:21 Não foi possível acessar ao banco de dados.
  4.  
  5. <IfModule mod_headers.c>
  6. Header set Access-Control-Allow-Origin *
  7. </IfModule>
  8.  
  9. <?php
  10.  
  11. header("Access-Control-Allow-Origin: *");
  12. header("Content-Type: text/html; charset=utf-8");
  13.  
  14. $data = file_get_contents("php://input");
  15. $objData = json_decode($data);
  16.  
  17. $dns = "mysql:host=mysql70.ramosdainformatica.com.br;dbname=ramosdainforma70";
  18. $user = "ramosdainforma70";
  19. $pass = "rain14570";
  20.  
  21.  
  22. $counter = $objData->counter;
  23. $token = $objData->token;
  24.  
  25. try {
  26. $con = new PDO($dns, $user, $pass);
  27.  
  28. if(!$con){
  29. echo "Não foi possivel conectar com Banco de Dados!";
  30. }
  31. if ($token === "1f3d2gs3f2fg3as2fdg3re2t1we46er45" && isset($token)) {
  32.  
  33.  
  34. $query = $con->prepare('SELECT * FROM usuario_app ORDER BY nome'.$counter.', 5'');
  35. $query->execute();
  36.  
  37.  
  38. $out = "[";
  39. while($result = $query->fetch()){
  40. if ($out != "[") {
  41. $out .= ",";
  42. }
  43. $out .= '{"cod_user: "'.$result["cod_user"].'",';
  44. $out .= '"nome": "'.$result["nome"].'",';
  45. $out .= '"pais": "'.$result["pais"].'",';
  46. $out .= '"cep": "'.$result["cep"].'"';
  47. $out .= '"logradouro": "'.$result["logradouro"].'",';
  48. $out .= '"complemento": "'.$result["complemento"].'",';
  49. $out .= '"bairro": "'.$result["bairro"].'",';
  50. $out .= '"cidade": "'.$result["cidade"].'"';
  51. $out .= '"estado": "'.$result["estado"].'",';
  52. $out .= '"celular": "'.$result["celular"].'",';
  53. $out .= '"email": "'.$result["email"].'",';
  54. $out .= '"senha": "'.$result["senha"].'"';
  55. $out .= '"data_cadastro": "'.$result["data_cadastro"].'",';
  56. $out .= '"latitude": "'.$result["latitude"].'",';
  57. $out .= '"longitude": "'.$result["longitude"].'"}';
  58.  
  59. }
  60. $out .= "]";
  61. echo $out;
  62.  
  63.  
  64. }
  65. } catch (Exception $e) {
  66. echo "Erro: ". $e->getMessage();
  67. };
  68.  
  69. (function(){
  70. "use strict";
  71.  
  72. angular.module("myApp").value("Config", {
  73.  
  74. getUrl: "http://www.ramosdainformatica.com.br/food/"
  75. });
  76.  
  77. angular.module("myApp").service("Data", function($http, Config){
  78. //recuperação de dados
  79. this.getData = function(params){
  80. return $http({
  81. method: "POST",
  82. url: Config.getUrl + "apinhac.php",
  83. data: params,
  84. headers : {
  85. 'Content-Type' : 'Access-Control-Allow-Origin: *; application/x-www-form-urlencoded; charset=UTF-8'
  86. }
  87. });
  88. };
  89.  
  90.  
  91. });
  92. })();
  93.  
  94. XMLHttpRequest cannot load http://www.ramosdainformatica.com.br/food/apinhac.php. Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
  95. app_controller.js:20 []
  96. app_controller.js:21 Não foi possível acessar ao banco de dados.
  97.  
  98. header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
  99. header('Access-Control-Allow-Credentials: true');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement