I am new to php and coding. I am trying simply to submit a form and all i am getting is a empty email message. Can anyone please help me to find what's my error?
My php code is:
<?php
$to = "webmaster@mywebsite.com";
$subject = "Contact Us";
$email = $REQUEST['email'] ;
$message = $REQUEST['body'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers, $fields) ;
$fields = array();
$fields{"name"} = "Name";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
if($sent)
{header( "Location: http://www.mywebsite.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please try again later."; }
?>
Thank you in advance!!!