Help - Registration Form

Asked

Viewed 142 times

0

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

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

Follows 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>

Follows 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");
}
  • When did you stop sending? After you climbed into the cloud?

  • Which hosting you are using?

1 answer

0

There are some things you can do to make sure your message is not blocked.

How to prevent the message from being blocked

  • Campo From: should be an email from your domain, otherwise you may have problems with receiving messages also because of the security lock of the servers of several providers;

  • Return-Path: should be the same e-mail specified in From, if it is not specified or a different email is specified, the message may not reach the destination because of the security lock of the servers of several providers;

  • Campo Reply-To: is ideal for forms that have the function of sending email to a mailbox of your own (@dominio.com), because when you reply, the recipient will be the visitor’s email. If you use the visitor email in the From field, the message can be barred because of the above topic.

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

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

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

Source: Locaweb

Also, depending on your hosting/server, there may be other factors like:

  • function mail requires configuration in htaccess authentication.
  • Limit your hosting shipments.
  • Other settings on header that your hosting requires.

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

Browser other questions tagged

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