我一直在尝试使用materializecss和PHP从我的联系表单发送消息。但由于一些奇怪的原因,我无法完成它。
我的PHP代码:
<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$message = strip_tags(htmlspecialchars($_POST['message']));
$to = 'soundharyabharatiya@gmail.com';
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply@soundharya.info\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
我的实体联系表格
<div class="container">
<div class="row">
<h4>Contact</h4>
<form action="contact_me.php" method="POST" class="col s12">
<div class="row">
<div class="input-field col s6">
<i class="material-icons prefix">account_circle</i>
<input id="icon_prefix" type="text" class="validate" name="name">
<label for="icon_prefix">Full Name</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">email</i>
<input id="email" type="email" class="validate">
<label for="email" data-error="wrong" data-success="right" name="email">Email</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">message</i>
<textarea id="textarea1" class="materialize-textarea" name="message"></textarea>
<label for="textarea1">Message</label>
</div>
</div>
</form>
</div>
<div class="container center">
<input type="submit" value="Send">
</div>
</div>
我甚至无法将一条消息发送到我的电子邮件ID。