0
Good afternoon, everyone,
I’m not an expert in php and I’m trying to make an email form, but when I click send it a blank screen appears, no errors and also no sent message, could anyone help me? Thank you. Code below
Form:
<div id="contact_form">
<div class="form-group">
<div class="row">
<div class="col-md-6">
<form action='/php/mail.php'>
<label>Nome<span class="required">*</span></label>
<input type="text" name="nome" class="form-control input-field" required="">
</div>
<div class="col-md-6">
<label>Cidade<span class="required">*</span></label>
<input type="text" name="cidade" class="form-control input-field" required="">
</div>
</div>
<div class="row">
<div class="col-md-12">
<label>Email<span class="required">*</span></label>
<input type="email" name="email" class="form-control input-field" required="">
</div>
</div>
<button type="submit" id="submit_btn" value="Submit" class="btn btn-primary">Enviar</button>
</div>
And php:
<?php
if (isset($_POST['BTEnvia'])) {
//Variaveis de POST, Alterar somente se necessário
//====================================================
$nome = $_POST['nome'];
$cidade = $_POST['cidade'];
$email = $_POST['email'];
//====================================================
//REMETENTE --> ESTE EMAIL TEM QUE SER VALIDO DO DOMINIO
//====================================================
$email_remetente = "[email protected]"; // deve ser uma conta de email do seu dominio
//====================================================
//Configurações do email, ajustar conforme necessidade
//====================================================
$email_destinatario = "[email protected]"; // pode ser qualquer email que receberá as mensagens
$email_reply = "$email";
$email_assunto = "Contato teste guru"; // Este será o assunto da mensagem
//====================================================
//Monta o Corpo da Mensagem
//====================================================
$email_conteudo = "Nome = $nome \n";
$email_conteudo .= "Email = $email \n";
$email_conteudo .= "Telefone = $cidade \n";
//====================================================
//Seta os Headers (Alterar somente caso necessario)
//====================================================
$email_headers = implode ( "\n",array ( "From: $email_remetente", "Reply-To: $email_reply", "Return-Path: $email_remetente","MIME-Version: 1.0","X-Priority: 3","Content-Type: text/html; charset=UTF-8" ) );
//====================================================
//Enviando o email
//====================================================
if (mail ($email_destinatario, $email_assunto, nl2br($email_conteudo), $email_headers)){
echo "</b>E-Mail enviado com sucesso!</b>";
}
else{
echo "</b>Falha no envio do E-Mail!</b>"; }
//====================================================
}
?>
The page
/php/mail.php
has more stuff, HTML etc.?– Sam
Hi Sam, yes, I just put in the same part of the form
– Lidiane Fernandes
Have you looked at the source code of the page what it shows? The form page is the same as where the form is sent?
– Sam
I’ve seen it, nothing shows up.
– Lidiane Fernandes