Contact form does not send some data fields

Asked

Viewed 89 times

0

I would like a help from you , I have checked everything here but I could not detect the error, the form can not send the data entered in the message fields and select, IE they arrive empty in the email.

<h2 class="main-heading">
             Entre em Contato Conosco
        </h2>
        <div class="divider-1"></div>
        <div class="row">
        <div class="col-md6 col-xs-12">
            <form method="post" class="contac-form" action="enviar.php">
                <div class="col-md-6">
                <div class="form-group">
                    <label for="name" class="sr-only-focusable">Nome</label>
                    <input type="text" class="form-control" name="name" id="name" required="required" placeholder="Nome">
                </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="email" class="sr-only-focusable">Email</label>
                        <input type="text" class="form-control" name="email" id="email" required="required" placeholder="Email">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="tel" class="sr-only-focusable">Telefone</label>
                        <input type="text" class="form-control" name="tel" id="tel" required="required" placeholder="Telefone">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="datevento" class="sr-only-focusable">Data do Evento</label>
                        <input type="date" class="form-control" name="datevento" id="datevento" required="required" placeholder="Data do Evento">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="hevento" class="sr-only-focusable">Horário do Evento</label>
                        <input type="time" class="form-control" name="hevento" id="hevento" required="required" placeholder="Horário do Evento">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="devento" class="sr-only-focusable">Duração do Evento</label>
                        <input type="time" class="form-control" name="devento" id="devento" required="required" placeholder="Duração do Evento">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="endevento" class="sr-only-focusable">Endereço do Evento</label>
                        <input type="text" class="form-control" name="endevento" id="endevento" required="required" placeholder="Endereço do Evento">
                    </div>
                </div>
                <div class="col-md-6">
                    <label for="select">Selecione o Brinquedo</label>
                    <div class="form-group">
                       <select class="form-control" id="select">
                           <option value="1">Basquete Eletrônio</option>
                           <option value="2">Cama Elástica Pequenao</option>
                           <option value="3">Cama Elástica Média</option>
                           <option value="4">Cama Elástica Grande</option>
                           <option value="5">Castelo Pula Pula Médio</option>
                           <option value="6">Castelo Pula Pula Gigante Bolha</option>
                           <option value="7">Futebol de Sabão</option>
                           <option value="8">Filmagem Aérea</option>
                           <option value="10">Locação de Som</option>
                           <option value="11">Mini Tobogã</option>
                           <option value="12">Máquina de Algodão Doce</option>
                           <option value="13">Modelagem com Balão</option>
                           <option value="14">Pintura Facial</option>
                           <option value="15">Pipoqueira Elétrica</option>
                           <option value="16">Piscina de Bolinha Inflável</option>
                           <option value="17">Piscina de Bolinha Casinha</option>
                           <option value="18">Quick Massagem para Festa</option>
                           <option value="19">Recreação</option>
                       </select>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label for="message">Mensagem</label>
                        <textarea class="form-control" id="message" rows="6"></textarea>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12" align="center">
                            <button class="btn btn-primary" type="submit">Enviar</button>
                    </div>
                </div>
            </form>
        </div>

this is the PHP code

<?php
/**
 * Created by PhpStorm.
 * User: Pedro
 * Date: 10/01/2017
 * Time: 09:45
 */


$name = $_POST['name'];
$email = $_POST['email'];
$tel =  $_POST['tel'];
$datevento = $_POST['datevento'];
$hevento = $_POST['hevento'];
$devento = $_POST['devento'];
$endevento = $_POST['endevento'];
$select = $_POST['select'];
$message = $_POST['message'];

$refresh = '<meta http-equiv=\"refresh\" content=\"1; url=form.html\" />';
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
{
    echo '<script type=\"text/javascript\">alert(\"E-mail inválido!.\")</script>';
    exit ($refresh);
} elseif
(!filter_var($email, FILTER_SANITIZE_EMAIL))
{
    echo '<script type=\"text/javascript\">alert(\"E-mail inválido!. Contém caracteres não permitidos.\")</script>';
    exit ($refresh);
}

 ($name != '' && $email != '' && $tel  != '' && $message != '');

    $msg = "<strong>Nome:</strong> $name<br>";
    $msg .= "<strong>E-mail:</strong> $email<br>";
    $msg .= "<strong>Telefone:</strong> $tel<br>";
    $msg .= "<strong>Data do Evento:</strong> $datevento<br>";
    $msg .= "<strong>Horário do Evento:</strong> $hevento<br>";
    $msg .= "<strong>Duração do Evento:</strong> $devento<br>";
    $msg .= "<strong>Endereço do Evento:</strong> $endevento<br>";
    $msg .= "<strong>Tipo de Brinquedo:</strong> $select<br>";
    $msg .= "<strong>Mensagem:</strong> $message<br>";
    $recipient = "[email protected]";
    $subject = "Formulário de Contato";
    $header = "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: text/html; charset=utf-8\r\n";
    $header .= "From: $email\r\n";


    (mail ($recipient, $subject, $msg, $header));

  echo "<p align=center>Mensagem Enviada com Sucesso!</p>";
echo "<p align=center>Retornaremos em breve!</p>";

echo "<script>window.location='index.html';alert('$name, sua mensagem foi enviada com sucesso! Estaremos retornando em breve');</script>";
?>

2 answers

0

Fields are sent by form based on the "name" attribute of the form.

In this case name is missing in select and textarea.

  • Guy was worth too much gave right here thanks so much for the help

0

Missing to put the attribute "name" in them

 <select class="form-control" id="select" name="select">
 <textarea class="form-control" id="message" rows="6" name="message">  </textarea>

Forehead

  • Guy was worth too much gave right here thanks so much for the help

Browser other questions tagged

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