Accentuation-Based Error [duplicate]

6

Hello

I'm developing a Hybrid APP that uses a PHP Webservice to send an email and call a procedure in MySQL by filling it with the same email data, until the part of sending the email is all OK it sends successfully, however at the moment I'm going to send the data to the procedure it just does not give the error and does not execute anything.

I created a PHP part with a form and the same webservice content that is used by APP, when I fill out the form I noticed that it mounts the GET URL by formatting the data by making the accents adjustments and removing the @ and replacing it with % 40 (ASCII code) and so the procedure runs successfully.

In the case of the App PHP Retrieves the data coming from the JSON sent by the APP and turns them into variables, have I tried to force an accent conversion but did not have any idea what to do?

Here are the codes:

APP Version

 <?php

Include("dbconect.php"); #DB Connector

if (!empty($_GET)) {

/* Recuperando Dados do GET */
$DestinoEmail = "[email protected]"; //Destino para o Email de     Notificação

$NomeCompleto  = $_GET['Nome'];
$TelefoneFixo  = $_GET['TelefoneFixo'];
$TelefoneMovel = $_GET['TelefoneMovel'];
$email         = $_GET['Mail'];
$cor           = $_GET['CorSelecionada'];
$Rg            = $_GET['NumeroRG'];
$cep           = $_GET['NumeroCEP'];
$assunto       = $_GET['AssuntoEmail'];
$descricao     = $_GET['descricaoEmail'];
$mobileID      = $_GET['MobileReg'];
$sexo          = $_GET['Sex'];
$nCasa         = "0";

/* Envia o email notificando */

#Corpo do Email
$msg= "<!DOCTYPE html>
    <html>
       <head>
          <meta charset='utf-8'>
          <style type='text/css'>
          body {

           color: #3A6EA5;
          }

          h5 {
              background-color: #3A6EA5;
              padding: 10px 30px 10px 30px;
              width: 950px;
          }
          </style>
       </head>
       <body>
          <p>&nbsp;</p>
          <p>Prezado $NomeCompleto,</p>
          <p>Seu Teste foi encaminhado com sucesso para nossa linha , favor aguarde retorno.</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
        </body>
    </html>";

# Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$assuntoMail = "Teste de Material";
#Codificar Assunto para aceitar os acentos 
$assunto_codificado = sprintf('=?%s?%s?%s?=', 'UTF-8', 'B', base64_encode($assuntoMail)); 
#Quebra de Linha caso a linha ultrapasse 70 caracteres
$msg = wordwrap($msg,70);
#Envio do Email
mail($DestinoEmail,$assunto_codificado ,$msg,$headers);

/*  Executar a Proc para armazenar os dados       */


$ncasa = "0";
$sth = $db->prepare('CALL     PR_REGISTER_REPORT(?,?,?,?,?,?,?,?,?,?,?,?,@out)');
$sth->bindParam(1,  $NomeCompleto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(2,  $TelefoneFixo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(3,  $TelefoneMovel, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(4,  $email, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(5,  $cor, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(6,  $Rg, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(7,  $cep, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(8,  $ncasa, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(9,  $mobileID, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(10, $sexo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(11, $assunto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(12, $descricao, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->execute();


//Retorno OK para o APP
$resultados["validate"] = "ok";
$resultadosJson = json_encode($resultados);
echo $_GET['jsoncallback'] . '(' . $resultadosJson . ');';


}else{

Echo "Interface Somente com APP";

}

?>

Test version (test-process.php)

<?php

  Include("dbconect.php"); #DB Connector

  if (!empty($_GET)) {

  /* Recuperando Dados do GET */
  $DestinoEmail = "[email protected]"; //Destino para o Email de       Notificação

  $NomeCompleto  = $_GET['Nome'];
  $TelefoneFixo  = $_GET['TelefoneFixo'];
  $TelefoneMovel = $_GET['TelefoneMovel'];
  $email         = $_GET['Mail'];
  $cor           = $_GET['CorSelecionada'];
  $Rg            = $_GET['NumeroRG'];
  $cep           = $_GET['NumeroCEP'];
  $assunto       = $_GET['AssuntoEmail'];
  $descricao     = $_GET['descricaoEmail'];
  $mobileID      = $_GET['MobileReg'];
  $sexo          = $_GET['Sex'];
  $nCasa         = "0";

  /* Envia o email notificando */

  #Corpo do Email
  $msg= "<!DOCTYPE html>
      <html>
       <head>
          <meta charset='utf-8'>
          <style type='text/css'>
          body {

           color: #3A6EA5;
          }

          h5 {
              background-color: #3A6EA5;
              padding: 10px 30px 10px 30px;
              width: 950px;
          }
          </style>
       </head>
       <body>
          <p>&nbsp;</p>
          <p>Prezado $NomeCompleto,</p>
          <p>Seu Teste foi encaminhado com sucesso para nossa linha , favor aguarde retorno.</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
        </body>
    </html>";

# Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$assuntoMail = "Teste de Material";
#Codificar Assunto para aceitar os acentos 
$assunto_codificado = sprintf('=?%s?%s?%s?=', 'UTF-8', 'B', base64_encode($assuntoMail)); 
#Quebra de Linha caso a linha ultrapasse 70 caracteres
$msg = wordwrap($msg,70);
#Envio do Email
mail($DestinoEmail,$assunto_codificado ,$msg,$headers);

/*  Executar a Proc para armazenar os dados       */


$ncasa = "0";
$sth = $db->prepare('CALL     PR_REGISTER_REPORT(?,?,?,?,?,?,?,?,?,?,?,?,@out)');
$sth->bindParam(1,  $NomeCompleto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(2,  $TelefoneFixo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(3,  $TelefoneMovel, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(4,  $email, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(5,  $cor, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(6,  $Rg, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(7,  $cep, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(8,  $ncasa, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(9,  $mobileID, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(10, $sexo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(11, $assunto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(12, $descricao, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->execute();


//Retorno OK para o APP
$resultados["validate"] = "ok";
$resultadosJson = json_encode($resultados);
echo $_GET['jsoncallback'] . '(' . $resultadosJson . ');';


}else{

echo"

<form action='test-process.php' method='get'>
Nome Completo:<br>
<input type='text' name='Nome' value=''><br>
Telefone Fixo:<br>
<input type='text' name='TelefoneFixo' value=''><br>
 Telefone Movel:<br>
<input type='text' name='TelefoneMovel' value=''><br>
  Email:<br>
<input type='text' name='Mail' value=''><br>
 Cor:<br>
<input type='text' name='CorSelecionada' value=''><br>
 NumeroRG:<br>
<input type='text' name='NumeroRG' value=''><br>
NumeroCEP:<br>
<input type='text' name='NumeroCEP' value=''><br>
 AssuntoEmail:<br>
<input type='text' name='AssuntoEmail' value=''><br>
  DescricaoEmail:<br>
<input type='text' name='descricaoEmail' value=''><br>
  MobileReg:<br>
<input type='text' name='MobileReg' value=''><br>
Sex:<br>
<input type='text' name='Sex' value=''><br>
<input type='submit' value='Submit'>
</form>";


}

?>

Any solution?

  

I tried to force get from utf8_decode ($ foo), and the entry with   utf8_encode ($ foo) but did not work = (

    
asked by anonymous 20.07.2016 / 13:12

1 answer

-1

try to use mysql_set_charset('utf8',$conec);

    
16.08.2016 / 17:43