Hey! I’m new with php and i made a little e-mail form. I can’t get the headers working. When an e-mail has a arrived, I want the sender’s email address to show up. Sorry my bad english. Here is the code:
<?php
if(isset($_POST['submit'])) {
$to = "myemail@mail.com";
$subject = "Testing";
$name_field = $_POST['name'];
$address_field = $_POST['address'];
$city_field = $_POST['city'];
$phone_field = $_POST['phone'];
$email_field = $_POST['email'];
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'To: My Name <myemail@mail.com>' . "
";
$headers .= 'From: $email_field' . "
";
$body = "Name: $name_field
Address: $address_field
City: $city_field
Phone: $phone_field
Email: $email_field
";
echo "Data has been submitted to $to!";
mail($to, $subject, $body, $headers);
} else {
echo "Viestin lähettäminen ei onnistunut";
}
?>
Please help me, i’m lost!