I have encountered a problem in making a contact form because I am not succeeding and I do not know why it does not work.
Following applied code:
HTML
<form name="sentMessage" id="contactForm" method="POST" action="contact_me.php" novalidate>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="SEU NOME*" id="name" required data-validation-required-message="Seu nome faltou.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="SEU E-MAIL*" id="email" required data-validation-required-message="Por favor, adicione um email.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="SEU TELEFONE*" id="phone" required data-validation-required-message="Por favor, adicione um telefone.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<textarea class="form-control" placeholder="SUA MENSAGEM*" id="message" required data-validation-required-message="Por favor, adicione uma mensagem."></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12 text-center">
<div id="success"></div>
<button type="submit" class="btn btn-xl anime">ENVIAR MENSAGEM</button>
</div>
</div>
</form>
PHP
<?php
if (!$_POST['submit'])
{
$quebra_linha = "\n";
$emailsender = "[email protected]";
$nomeremetente = $_REQUEST['name'];
$emaildestinatario = "[email protected]";
$assunto = "[CONTATO] SITE RESPONSAVEL";
$mensagem = $_REQUEST['message'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$mensagemHTML = ' Olá,
tenho uma nova mensagem para você diretamente do site!
Nome: '.$nomeremetente.' Assunto: '.$empresa.' E-mail: '.$email.' Telefone: '.$phone.' Mensagem: '.$mensagem.'';
$headers = "MIME-Version: 1.1".$quebra_linha;
$headers = "Content-type: text/html; charset=iso-8859-1".$quebra_linha;
$headers = "From: ".$emailsender.$quebra_linha;
$headers = "Reply-To: ".$emailsender.$quebra_linha;
if (mail($emaildestinatario, $assunto, $mensagemHTML, $headers, "-r". $emailsender)) {
echo "";
echo "";
} else {
echo "";
}
}
?>
Apparently the action=""
is not redirecting when I press the submit
button. I tried with PHPMailer too, but I encounter the same problem.
The index was saved as index.php and I tried to use PHP_SELF
, but I did not get much success either.