0
I have a contact form on a website I made, but the email is coming with the blank form fields. Someone can help me?
The email arrives all right however the value of $_POST["nome"]
is coming blank.
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Mensagem enviada com sucesso!'
);
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$mensagem = $_POST['mensagem'];
$email_from = $email;
$email_to = '[email protected]';
$body = 'Nome: ' . $nome . "\n\n" . 'Email: ' . $email . "\n\n" . 'Telefone: ' . $telefone . "\n\n" . 'Mensagem: ' . $mensagem;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
<form id="main-contact-form" class="contact-form" name="contact-form" method="POST" action="sendemail.php">
<div class="row-fluid">
<div class="span5">
<label>Nome</label>
<input type="text" id="nome" name="nome" class="input-block-level" required="required">
<label>Email</label>
<input type="email" class="input-block-level" required="required" id="email" name="email">
<label>Telefone</label>
<input type="text" class="input-block-level" required="required" id="telefone" name="telefone">
</div>
<div class="span7">
<label>Mensagem</label>
<textarea name="mensagem" id="mensagem" required="required" class="input-block-level" rows="8" style="height: 222px;"></textarea>
</div>
</div>
<button type="submit" class="btn btn-primary btn-large pull-right">Enviar mensagem</button>
<p> </p>
</form>
Possible duplicate of Feedback message in php contact form
– Marcelo Batista
You are separating the php form?
– adventistaam
in his case, he wants a modal with sent message to appear. In my case, the email arrives all right, but the amounts received in the $_POST["name"] is coming blank
– Vinib
yes, they are in separate files
– Vinib
I just tested your code and it’s working
– adventistaam
Here for me the email arrives as follows... Name: Email: Phone: Message:
– Vinib
gives a var_dump($_POST) to see what returns
– adventistaam
The page
sendemail.php
only has PHP code above or has something else?– Sam
only has php code above
– Vinib
what returned in var_dump?
– adventistaam
returned NULL..
– Vinib
I’m guessing it’s the client’s server. has a chance to be?
– Vinib