1
The page is:
http://www.hotplateprensas.com.br/_required/Email2.php
The code is:
<?php
require_once "../_controlls/_conexao/Conexao.php";
require_once "../_controlls/_util/PhpUtil.php";
require_once "../_controlls/_models/Emails.php";
require_once "../_controlls/_daos/EmailsDao.php";
require_once "../_controlls/_util/Constantes.php";
$connection = new Conexao();
$conexao = $connection->abreConexao();
$constantes = new Constantes();
$phpUtil = new PhpUtil();
$_POST["assunto"] = 1;
$_POST["nome"] = "Caca";
$_POST["email"] = "[email protected]";
$_POST["telefone"] = 3333333333;
$_POST["descricao"] = "Teste";
$_POST["qual"] = "";
$assunto = $phpUtil->contatoTipos($_POST["assunto"]);
$emailsDao = new EmailsDao($conexao);
$email = new Emails(
date("Y-m-d"),
"n",
$_POST["nome"],
$_POST["email"],
preg_replace( '#[^0-9]#', '', $_POST["telefone"] ),
$_POST["assunto"],
$_POST["descricao"]);
$emailsDao->cadastrar($email);
$outro = $_POST["assunto"] == 6 ? "<b>Qual:</b> ".$_POST["qual"]."<br /><br />" : "";
$texto = "<h2>".$constantes->getTituloSite()."</h2><br />";
$texto .= "<img style='display:block; margin:0 auto;' src='".$constantes->getHttpSite()."/_img/logo.png' />";
$texto .= "<b>Olá, você nos enviou um e-mail com a seguinte mensagem:</b><br /><br />";
$texto .= "<b>Nome:</b> ".$_POST["nome"]."<br /><br />";
$texto .= "<b>Telefone:</b> ".$_POST["telefone"]."<br /><br />";
$texto .= "<b>E-mail:</b> ".$_POST["email"]."<br /><br />";
$texto .= "<b>Interesse:</b> ".$assunto."<br /><br />";
$texto .= $outro;
$texto .= "<b>Descrição:</b><br />".nl2br($_POST["descricao"])."<br /><br /><br />";
$texto .= "Estaremos respondendo o mais rápido possível<br /><br />";
require_once "../_controlls/_models/EmailEnviar.php";
require_once "../_controlls/_daos/EmailEnviarDao.php";
$html = "<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>".$constantes->getTituloSite()."/title>
</head>
<body>".$texto."</body>
</html>";
$assuntoCodificado = sprintf('=?%s?%s?%s?=', 'UTF-8', 'Q', quoted_printable_encode("Re: ".$assunto));
$emailEnviar = new EmailEnviar(
$_POST["nome"],
$_POST["email"],
$constantes->getTituloSite(),
"[email protected]",
$assuntoCodificado,
$texto
);
$emailEnviarDao = new EmailEnviarDao();
$enviarEmail = $emailEnviarDao->enviaEmail($emailEnviar);
if ($enviarEmail["success"] == 1) {
var_dump ("OK");
} else {
var_dump ("ERRO");
}
?>
When right, the html
should retornar
"OK"
When it goes wrong, the html
should retornar
"ERROR"
In fact this is happening. However, with spaces at the beginning.
" OK", and " ERROR"
This is causing me trouble at the time catch this result with JQuery AJax
This could be solved by giving a trim
in the ajax
but I would like to understand where this white space is coming from since none of the files involved has GOOD signature.
Exit html
in the Ctrl+U
Check if there is an echo in any imported file, it does not seem to come from that file
– Denis Rudnei de Souza
I searched them all. None has echo. Since they are classes or function files only have Returns
– Carlos Rocha
Go echo '1'; echo '2'; echo '3'; and successively by the code you will see on which stretch the space is inserted. Much faster than breaking your head. Put the first one right after the <?php , after the require/includes etc. Where the space appears, you will surround.
– Bacco