我的邮件php在更改htaccess url后无效,我是php和htaccess的新手,无法弄清楚出了什么问题。有人可以帮忙吗?
的index.html
` <form method="post" name="sentMessage" id="contactForm" novalidate>
mail.php
`<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$to = 'jondmk@jondmk.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@jondmk.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
的.htaccess
`ErrorDocument 404 /filenotfound.html
IndexIgnore *
RewriteEngine On
RewriteRule ^home index.html [NC,L]
RewriteRule ^education about.html [NC,L]
RewriteRule ^work project.html [NC,L]
RewriteRule ^my_blog blog/blog.html [NC,L]
RewriteRule ^about_me blog/about.html [NC,L]
RewriteRule ^contact_me blog/contact.html [NC,L]
谢谢你的时间!
答案 0 :(得分:0)
您的HTML表单未发布到正确的文件。你应该指定要POST的文件,在你的情况下它是mail.php
将您的开始表单标记更改为
<form method="post" name="sentMessage" id="contactForm" action="mail.php" novalidate>