I'm using a the following to have a contact page send me a email with visitors data.
<form method="post" action="submit.php">
<label for="Name">Name</label>
<input type="text" name="Name" id="Name" />
<label for="Email">eMail</label>
<input type="text" name="Email" id="Email" />
<input type="submit" name="submit" value="Send" class="submit-button" />
</form>
and the php:
<?php
$EmailFrom = "Me";
$EmailTo = "me@me.com";
$Subject = "Test";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "eMail: ";
$Body .= $Email;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
When trying it out I only get the email body text prepared by the PHP file but none of the information inserted by the visitor, like this:
Name: eMail: