I took the code below from a website but it only seems to send the Message and not the Name or Email. Can anyone tell me why?
<?php $action=$_REQUEST['action'];
if ($action=="") { ?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else {
$message=$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: dG<my@email.com>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("my@email.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
I thought that I could change
mail("my@email.com", $subject, $message, $from);
to be more like
mail("my@email.com", $subject, $name, $email, $message, $from);
but that didn't work. As you can see, I don't know much about PHP, so please keep it as simple as you can.
Thanks.