Contact form with blank data

Asked

Viewed 77 times

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

  • You are separating the php form?

  • 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

  • yes, they are in separate files

  • I just tested your code and it’s working

  • Here for me the email arrives as follows... Name: Email: Phone: Message:

  • gives a var_dump($_POST) to see what returns

  • The page sendemail.php only has PHP code above or has something else?

  • only has php code above

  • what returned in var_dump?

  • returned NULL..

  • I’m guessing it’s the client’s server. has a chance to be?

Show 7 more comments
No answers

Browser other questions tagged

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