0

I have a html form, which is sending the data through POST to the php-file, and the php-file should process the data (make a good looking structure) and send it via mail.

But the $_POST variable is completely empty....

I have this small html form:

<form id="form" method="post" action="formmailer.php">
            <div id="input1">
                <input name="name" type="text" placeholder="Ihr Name"> <br>
                <input name="email" type="email" placeholder="Ihre E-Mail"> <br>
            </div>
            <div id="input2">
                 <textarea name="nachricht" rows="10" cols="30"></textarea> <br>
                 <input type="submit" value="" name="submit" id="submit">
             </div>
</form>

And formmailer.php uses these variables:

<?php // 

if(isset($_POST['nt']) && isset($_POST['ntb'])) 
{


// 
$an = "[email protected]";
$name = $_POST['name'];
$email = $_POST['email'];
$nachricht = $_POST['nachricht'];

// Mailheader UTF-8 
$mail_header = 'From:' . $email . "n";
$mail_header .= 'Content-type: text/plain; charset=UTF-8' . "rn";

// create layout
$message = "
Name:       $name 
Email:      $email 
Nachricht:  $nachricht 
";

// send mail
mail($an, $message, $mail_header );
}
else {
   echo("<p>Email delivery failed…</p>");
  }

?>

If i use this if-statement

if (isset($_POST["submit"]))

the mail is sending, but completely empty.

Am i blind? It should be really easy, shouldn't it?

2
  • if(isset($_POST['nt']) && isset($_POST['ntb'])) Commented Aug 23, 2013 at 19:34
  • where is 'nt' and 'ntb' in the html? Commented Aug 23, 2013 at 19:37

2 Answers 2

2
isset($_POST['nt']) && isset($_POST['ntb'])

In html I do not find nt and ntb field.

When you use isset($_POST["submit"]). In Post array php find submit value. But you did not enter any value in the form fields that is why you getting empty value in your mail.

Sign up to request clarification or add additional context in comments.

Comments

0

Replace this line from formmailer.php

if (isset($_POST['nt']) && isset($_POST['ntb']))

to:

if ($_POST)

I hope this helps.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.