I'm making a email form on my website. For some reason, I cannot get email from this form.
html
<form method="POST" action="processor.php" id="contactform" onsubmit="return(validateForm());">
<div>
<label for="fname">First Name:<br></label>
<input type="text" name="fname" id="fname" value="" class="required"/>
</div>
<div>
<label for="lname">Last Name:<br></label>
<input type="text" name="lname" id="lname" value="" class="required"/>
</div>
<div>
<label for="organization">Organization:<br></label>
<input type="text" name="organization" id="organization" value="" class="required"/>
</div>
<div>
<label for="email">Email:<br></label>
<input type="text" name="email" id="email" value="" class="required email" />
</div>
<div>
<label for="phone">Phone:<br></label>
<input type="text" name="phone" id="phone" value="" class="required" />
</div>
<div>
<label for="message" style="line-height: 2;">Message:<br></label>
<textarea rows="20" cols="20" name="message" id="message"></textarea>
</div>
<input id="submit" name="submit" type="submit" class="submit-button myButton" value="Send" />
<div class="clearfix"></div>
</form>
PHP
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) > 7 || !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
die("Bad referer");
$msg = "Website Message:
";
foreach ($_POST as $key => $val) {
if (is_array($val)) {
$msg .= "Item: $key
";
foreach ($val as $v) {
$v = stripslashes($v);
$msg .= " $v
";
}
} else {
$val = stripslashes($val);
$msg .= "$key: $val
";
}
}
$recipient = "test@example.com";
$subject = "Website Contact Form Filled Out";
error_reporting(0);
if (mail($recipient, $subject, $msg)) {
header("Location: http://www.example.com/thankyou.html");
} else
echo "An error occurred and the message could not be sent.";
} else
echo "Bad request method";
?>
The thing is the PHP code works because the it worked with the other HTML form. I am wondering the way of HTML coding is the reason or not. If anybody know PHP and form well, please help me. Thank you!