Help - Registration Form

0

Good afternoon! I made a very simple registration form that sends the data to the e-mail. It was running 100% and simply stopped sending the emails.

After all the registration, clicking on "send" the user is usually redirected to the "registration completed" page but the email is not sent.

Follow the HTML:

<body>
<div id="header"></div>
<div class="linha">
    <section>
        <div>

        <!--formulário de cadastro -->
        <form  style="margin: 2%;" id="cadastro" name="formCadEmpre"  method="post" action="cadastroEmpresa.php" onsubmit="return validaCampo(); return false;">

            <!--dados do representante-->
            <fieldset id="dadosrepres" class="coluna col6"> 
                <legend> Dados do Representante legal </legend>

                <!--nome-->
                <p style="margin-top: 18pt;"><label for="cNome"></label><input required="" type="text" name="tNome" id="cNome" size="20" maxlength="60" minlength="10" placeholder="Nome Completo do responsável"></p>

                <!--Email-->
                <p><label for="cEmail"></label> <input required="" type="email" name="tEmail" id="cEmail" maxlength="60" minlength="8" placeholder="E-mail do responsável"></p>

                <!--celular-->
                <p><label for="cCelular"></label> <input required="" onkeypress="mascara( this, mcel ); " type="numero" name="tCelular" id="cCelular" maxlength="15" minlength="13" placeholder=" Celular para contato ( Apenas números )"></p><br>
            </fieldset>

            <!--dados do estabelecimento-->
            <fieldset id="dadosestabel" class="coluna col6">
                <legend>Dados do Estabelecimento</legend>

                <!-- nome fantasia -->
                <p><input required="" type="text" name="tFantasia" id="cFantasia" maxlength="30" placeholder="Nome do seu Estabelecimento"></p>

                <!--CNPJ -->
                <p><input required="" onkeypress="mascara( this, cnpj );" type="text" name="tCNPJ" id="cCNPJ" maxlength="18" minlength="18" placeholder="CNPJ do seu Estabelecimento ( apenas números )" ></p>

                <!--telefone-->
                <p><input required="" type="text"  onkeypress="mascara( this, mtel );" name="tTelefone" id="cTelefone" maxlength="15" minlength="13" placeholder="Telefone do seu estabelecimento (apenas números)"></p>

                <!--Atividade da empresa-->
                <p><label for="cAtividade"></label>
                <select name="tAtividade" id="cAtividade">
                    <option>Atividade principal da empresa</option><option>Água e gás</option><option>Alimentos & Bebidas</option><option>Animais Domésticos</option><option>Artigos de Festa</option><option>Artigos Esportivos</option><option>Cama mesa e banho</option><option>Cosméticos</option><option>Decoração</option><option>Farmácia</option><option>Jardinagem</option><option>Materiais de Construção</option><option>Moda</option><option>Padaria</option><option>Peças Automobilísticas</option><option>Suplementos</option><option>Vidraçaria</option><option>Outros</option>
                </select></p>
            </fieldset>

            <!--endereço do estabelecimento-->
            <fieldset id="enderecoestabel">
                <legend>Endereço do estabelecimento</legend>

                <!--Cep-->
                <p><label for="cCep"></label>
                <input required="" type="text" onkeypress="mascara( this, mcep );" name="tCep" id="cCep" maxlength="9" minlength="9" placeholder="CEP ( apenas números )">

                <!--estado-->
                <label for="cEstado"></label>
                    <select name="tEstado" id="cEstado">
                        <optgroup label="Nordeste">
                            <option value="Alagoas">Alagoas</option><option value="Bahia">Bahia</option><option value="Ceará">Ceará</option><option value="Maranhão">Maranhão</option><option value="Paraíba">Paraíba</option><option value="Pernambuco" selected>Pernambuco</option><option value="Piauí">Piauí</option><option value="Rio Grande do Norte">Rio grande do Norte</option><option value="Sergipe">Sergipe</option>
                        </optgroup>
                    </select>
                </p>

                <!--cidade-->
                <p><label for="cCidade"></label>
                    <input required="" type="text" name="tCidade" id="cCidade" placeholder="Cidade do Estabelecimento" maxlength="40" list="cidades">
                    <datalist id="cidades">
                        </option><option value="Abreu e lima"></option><option value="Araçoiaba"></option><option value="Cabo de santo Agostinho"></option><option value="Camaragibe"></option><option value="Igarassu"></option><option value="Ilha de Itamaracá"></option><option value="Ipojuca"></option><option value="Itapissuma"></option><option value="Jaboatão dos guararapes"></option><option value="Moreno"></option><option value="Olinda"></option><option value="Paulista"></option><option value="Recife"></option><option value="São Lourenço da Mata"></option>
                    </datalist>

                <!--Bairro-->
                <label for="cBairro"></label>
                <input required="" type="text" name="tBairro" id="cBairro" maxlength="30" placeholder="Bairro do Estabelecimento"></p>

                <!--Endereço-->
                <p><label for="cEndereço"></label>
                <input required="" type="text" name="tEndereco" id="cEndereco" maxlength="60" placeholder="Endereço do estabelecimento Ex: Av. Boa viagem 321"></p>

                <!--Complemento-->
                <p><label for="cComplemento"></label>
                <input required="" type="text" name="tComplemento" id="cComplemento" maxlength="60" placeholder="Complemento Ex: bloco A numero 13"></p>
            </fieldset>
            <input type="submit" value="Enviar dados para analise" onclick="return validar()" id="inputcadastro">
        </form>     
        </div>  
    </section>
</div>

Follow PHP

   include_once('connect/connectdb.php');

$para = "[email protected]";

$assunto = "Cadastro Parceiro";

//inserindo dados na tabela

$celular = $_POST ["tCelular"];

$email = $_POST ["tEmail"];

$nome = $_POST ["tNome"];

$fantasia = $_POST["tFantasia"];

$telefone = $_POST["tTelefone"];

$CEP = $_POST["tCep"];

$atividade = $_POST["tAtividade"];

$estado = $_POST["tEstado"];

$cidade = $_POST["tCidade"];

$bairro = $_POST["tBairro"];

$product = $_POST["tendereco"];

$complemento = $_POST["tComplemento"];

$CNPJ = $_POST["tCNPJ"];


$dbh = open_connection_database();

$sql = "SELECT idsupplier FROM supplier WHERE email= :email";

$stmt = $dbh->prepare($sql);

$stmt->bindParam(':email', $login);

$stmt->execute();

$idsuppliers = $stmt->fetchAll(PDO::FETCH_ASSOC);

if (count($idsuppliers) >= 1) {
    echo '<script> history.go(-1); alert("Email ja cadastrado no sistema!");
</script>';

} else {
    $corpo = "<strong> Um novo cadastro foi realizado! </strong><br><br>";

    $corpo .= "<h1>Dados do Representante</h1><br><strong> Nome: </strong> $nome";

    $corpo .= "<br><strong> Celular: </strong> $celular";

    $corpo .= "<br><strong> Email: </strong> $email<br><br>";

    $corpo .= "<h1>Dados do Estabelecimento</h1><br><strong> Nome Fantasia: </strong> $fantasia";

    $corpo .= "<br><strong> CNPJ: </strong> $CNPJ";

    $corpo .= "<br><strong> Telefone: </strong> $telefone";

    $corpo .= "<br><strong> CEP: </strong> $CEP";

    $corpo .= "<br><strong> Atividade: </strong> $atividade";

    $corpo .= "<br><strong> Estado: </strong> $estado";

    $corpo .= "<br><strong> Cidade: </strong> $cidade";

    $corpo .= "<br><strong> Bairro: </strong> $bairro";

    $corpo .= "<br><strong> Endereço: </strong> $endereco";

    $corpo .= "<br><strong> Complemento: </strong> $complemento";


    $header = "Content-type: text/html; charset= utf-8\n";

    $header .= "From: $email Reply-to: $email\n";

    mail($para, $assunto, $corpo, $header);

    header("location:cadConcluido.html");
}
    
asked by anonymous 08.05.2017 / 19:36

1 answer

0

There are a few things you can do to keep your message from being blocked.

How to prevent the message from being blocked

  • From field : it should be an email from your domain, otherwise you may have problems receiving messages also because of the security blocking of servers from various providers;

  • Return-Path : Should be the same email specified in From, if it is not specified or a different email is specified, the message may not reach the destination by account of the security block of the servers of several providers;

  • Reply-To field: it is ideal for forms that have the function of sending email to a mailbox of your (@ domain.com), because when it responds, the recipient will be the visitor's email . If you use the visitor's email in the From field, the message may be barred because of the topic above.

Note: It is important to use "Return-Path" to receive the return of the messages and to identify the sending faults more quickly.

That is, in your case the Return-Path, may be the cake cherry that is missing.

$headers .= "Return-Path: [email protected]\n";

Source: locaweb

In addition, depending on your hosting / server, there may be other factors such as:

  • function mail needs configuration in htaccess authentication.
  • Upload limit for your hosting.
  • Other settings on the% w_that your hosting requires.

However, I advise you to use phpMailer , which in my opinion is easier to use and you will get 100% of shipping. See the Thiago Belém tutorial .

    
09.05.2017 / 16:59