我的页面上有几个简单的联系表单。 直到我添加了这个.htaccess文件,所有的工作都很好(表单已发送到脚本中的电子邮件)。PHP表单与.htaccess冲突
有没有办法处理PHP表单,同时还包括.htaccess文件? (因为它使网站看起来非常好)
在此先感谢。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase/
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule^%1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule^%{REQUEST_URI}.php [L]
表单代码:
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$from = 'From: Contact Page';
$to = '[email protected]';
$subject = 'Contact Page';
$human = $_POST['human'];
$body = "From: $first_name\n $last_name\n E-Mail: $email\n Phone: $phone\n Message:\n $message";
if ($_POST['submit'] && $human == '4') {
if (mail ($to, $subject, $body, $from)) {
header('Location: http://www.xxxxxx.com/ThankYou.php');
exit();
} else {
header('Location: http://www.xxxxxx.com/error.php');
}
} else if ($_POST['submit'] && $human != '4') {
header('Location: http://www.xxxxxx.com/error.php');;
}
?>
是什么形式的动作我以前的答案吗?为什么你不知道你在做什么而添加一个服务器配置? – donald123
你可以添加表单代码吗? – versalle88
表单正在发布。我添加了它,因为我知道我想要它做什么;)(这是为了使网址很好)如果我总是知道我在做什么,我什么都不会做;) – newneub