City and zip code information behaving strange. PHP Mailer, Html

Asked

Viewed 29 times

-2

Hello community all right?

I have a very strange problem. I have an html form, and a php Mailer program that sends the mapped information. However only 2 fields behave very strange, the fields City and ZIP.

This is how I get:

Campos CEP e Cidade recebidos no e-mail

Below I will leave only structure of the fields and php Mailer.

            <div id="cadastro-basico">
                <label for="nome-empresa">Nome da Empresa</label>
                <input type="text" id="nome-empresa" class="input-padrao" required name="nomeempresa">

                <label for="cnpj-empresa">CNPJ da Empresa</label>
                <input type="text" id="cnpj-empresa" class="input-padrao" required name="cnpjempresa">

                <label for="pessoa-contato">Pessoa de contato</label>
                <input type="text" id="pessoa-contato" class="input-padrao" required name="pessoacontato">

                <label for="setor-contato">Setor onde o Contato atua dentro da empresa</label>
                <input type="text" id="setor-contato" class="input-padrao" required name="setorcontato">

                <label for="estado">Estado</label>
                <input type="text" id="estado" class="input-padrao" required placeholder="SP, RJ, MG, etc..  " name="estado">

                <label for="cidade">Cidade</label>
                <input type="text" id="cidade" class="input-padrao" required placeholder="São Paulo, Belo Horizonte, Salvador, etc.." name="cidade">

                <label for="cep">CEP</label>
                <input type="text" id="cep" class="input-padrao" required placeholder="XXXXX-XXX" name="cep" pattern="[0-9]*">

                <label for="email">Email da Pessoa de Contato</label>
                <input type="email" id="email" class="input-padrao" required placeholder="[email protected]" name="email">

                <label for="telefone">Telefone da Pessoa de Contato</label>
                <input type="tel" id="telefone" class="input-padrao" required placeholder="(XX) XXXXX-XXXX" name="telefone">

...................................................

Php Mailer

<?php

if (isset($_POST['email']) && !empty($_POST['email'])) {

$nome = addslashes($_POST['nomeempresa']);
$cnpj = addslashes($_POST['cnpjempresa']);
$contatoPessoa = addslashes($_POST['pessoacontato']);
$setor = addslashes($_POST['setorcontato']);
$estado = addslashes($_POST['estado']);
$cidade = addslashes($_POST['cidade']);
$cep = addslashes($_POST['cep']);
$email = addslashes($_POST['email']);
$telefone = addslashes($_POST['telefone']);
$contato = addslashes($_POST['contato']);
$preferencia = addslashes($_POST['preferenciaContato']);
$motivo = addslashes($_POST['motivoContato']);
$vidro = addslashes($_POST['reciclaveisvidro']);
$vidro1 = addslashes($_POST['produtoespecifico1']);
$borracha = addslashes($_POST['reciclaveisborracha']);
$borracha1 = addslashes($_POST['produtoespecifico2']);
$organico = addslashes($_POST['reciclaveisorganico']);
$organico1 = addslashes($_POST['produtoespecifico3']);
$reee = addslashes($_POST['reciclaveisreee']);
$reee1 = addslashes($_POST['produtoespecifico4']);
$quimico = addslashes($_POST['reciclaveisquimico']);
$quimico1 = addslashes($_POST['produtoespecifico5']);
$papel = addslashes($_POST['reciclaveispapel']);
$papel1 = addslashes($_POST['produtoespecifico6']);
$madeira = addslashes($_POST['reciclaveismadeira']);
$madeira1 = addslashes($_POST['produtoespecifico7']);
$tecido = addslashes($_POST['reciclaveistecido']);
$tecido1 = addslashes($_POST['produtoespecifico8']);
$plastico = addslashes($_POST['reciclaveisplastico']);
$plastico1 = addslashes($_POST['produtoespecifico9']);
$metais = addslashes($_POST['reciclaveismetais']);
$metais1 = addslashes($_POST['produtoespecifico10']);
$rcc = addslashes($_POST['reciclaveisrcc']);
$rcc1 = addslashes($_POST['produtoespecifico11']);
$sucata = addslashes($_POST['reciclaveissucata']);
$sucata1 = addslashes($_POST['produtoespecifico12']);
 
 $body = "Nome: ".$nome. "\r\n".
        "CNPJ: ".$cnpj. "\r\n".
        "Pessoa de Contato: ".$contatoPessoa. "\r\n".
        "Setor da Pessoa de Contato: ".$setor. "\r\n".
        "Estado: ".$estado. "\r\n".
        "Cidade: ".$cidade. "\r\n".
        "CEP: ".$cep. "\r\n".
        "E-mail: ".$email. "\r\n".
        "Telefone: ".$telefone. "\r\n".
        "Contato: ".$contato. "\r\n".
        "Prefernencia de Contato: ".$preferencia. "\r\n".
        "Motivo do Contato: ".$motivo;

$from = "[email protected]";
    
$to = "[email protected], [email protected]";  

$subject = "Pedido cadastrado!";

$message = "Essa e uma mensagem de teste.";

$header = "From:[email protected]"."\r\n".

"Reply-To: ".$email."\r\n".

"X=Mailer:PHP/".phpversion();

 if(mail ($to,$subject,$body,$header)){
    echo ("E-mail enviado com sucesso");

 } else {
    echo ("E-mail não pode ser enviado");

}

}



?>

You could help me?

  • Nicolas your question has a lot of stuff, I recommend you reduce the code posted and preferably simulate an abstract version of your problem so that we can prove, this is probably a debug problem, somewhere in your code you’re doing something you shouldn’t and it’s not our job to debug the code for you. Try to edit your question for greater chances of getting a good answer.

1 answer

0

Try to change the id’s of these fields that are being wrongly loaded, and perform the mapping again.

If you need to debug, use print_r(array).

Browser other questions tagged

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