html - Php contact form with validation not working -


hi i've created contact form send messages.
i've read many times , haven't found wrong. tip?
when press "enviar" (send) nothing happens. i've createad new form option field related "subject" ("assunto").
ps.:plz ignore "mail@mail.com.br", in tests i'm using real one.

hope can help!

this php code i've inserted before form tag. it's code i've seen here i've changed work site.

<?php $page = 'contact';        $to = "mail@mail.com.br";      //$subject = "company - contato";       if (isset($_post['submit'])) {           // error checking          $errors = array();           // name check          if (empty($_post['name'])) {              $errors[] = 'preencha corretamente o campo nome.';          }           // email check          if (empty($_post['email'])) {              $errors[] = 'preencha corretamente o campo email.';          }           // assunto check          if (empty($_post['assunto'])) {              $errors[] = 'preencha corretamente o campo assunto.';          }           // message check          if (empty($_post['message'])) {              $errors[] = 'preencha corretamente o campo mensagem';          }           // if no errors - send email          if (empty($errors)) {               $name           = htmlentities($_post['name']);              $email          = htmlentities($_post['email']);              $assunto        = htmlentities($_post['assunto']);               $subject = 'company - contato';               $headers  = "from: $email" . "\r\n";              $headers .= "reply-to: $email" . "\r\n";              $headers .= "mime-version: 1.0\r\n";              $headers .= "content-type: text/html; charset=iso-8859-1\r\n";               $message = $_post['message'];              $message = '<html><body>';              $message .= "<br />";              $message .= "<br />";              $message .= '<div style="font: 14px arial, sans-serif; color: #333;">';              $message .= "<b>nome:</b> $name" . "\r\n";              $message .= "<br />";              $message .= "<b>email:</b> $email" . "\r\n";              $message .= "<br />";              $message .= "<b>assunto:</b> $assunto" . "\r\n";              $message .= "<br />";              $message .= "<b>mensagem:</b>";              $message .= "<br />";              $message .= $_post['message'];              $message .= "<br />";              $message .= '</div>';              $message .= "</body></html>";               // send email              mail($to,$subject,$message,$headers);               // set sent variable allow sent message displayed              $sent = 'sent';           }       }      ?>       <?php if (!empty($errors)) { ?>          <div class="error">              <ul>                  <?php                   foreach ($errors $error) {                      echo '<li>'.$error.'</li>';                  }                   ?>              </ul>          </div>      <?php } ?>       <?php if(isset($sent)) { ?>          <div class="success">              <p>sua mensagem foi enviada com sucesso.</p>         </div>      <?php } ?> 



below i've inserted form itself. can see, i've used same 'names', it's not working. :/

    <form name="htmlformcontato" class="form-horizontal"  action="" accept-charset="utf-8" method="post">       <div class="col-sm-6 col-xs-12">                <div class="form-group col-sm-12">               <label for="inputnome" class="control-label">nome *</label>               <input id="inputnome" type="text" class="form-control" name="name" value="<?php echo $_post['name']; ?>" />               </div>                 <div class="form-group col-sm-12">               <label for="inputemail" class="control-label">email *</label>               <input id="inputemail" type="text" class="form-control" name="email" value="<?php echo $_post['email']; ?>" />               </div>                 <div class="form-group col-sm-12">               <label for="inputassunto" class="control-label">assunto *</label>               <select class="form-control" name="assunto">                 <option value="selecioneassunto">selecione o assunto</option>                 <option value="duvidas">dúvidas</option>                 <option value="sugestoes">sugestões</option>                 <option value="reclamacoes">reclamações</option>                 <option value="outro">outro</option>               </select>               </div>                                        </div>       <div class="col-sm-6 col-xs-12">                <div class="form-group col-sm-12">               <label for="inputmensagem" class="control-label">mensagem *</label>               <textarea class="form-control" rows="9" id="inputmensagem" name="message"><?php echo $_post['message']; ?></textarea>               </div>      </div>      <div class="col-xs-12">                <div class="form-group col-xs-12">                         <button type="submit" class="btn btn-bodyupa">enviar</button>                         </div>      </div>                </form>                                                      

doesn't matter if use input or button long have type="submit" have set name since have if (isset($_post['whatevername'])) {

<button name="whatevername" type="submit" class="btn btn-bodyupa">enviar</button> 

or

<input name="whatevername" type="submit" class="btn btn-bodyupa" value="enviar"> 

either work fine.

also <button> vs. <input type="button" />. use?


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -