为了账号安全,请及时绑定邮箱和手机立即绑定

PHP 在某些目录中运行,但在其他目录中不运行

PHP 在某些目录中运行,但在其他目录中不运行

PHP
繁华开满天机 2021-11-19 16:56:34
我有几个简单的 html 网站,带有通过 PHP 发送电子邮件的联系表格。它们都很好用,完全没有问题。我现在正在尝试使用相同的联系表单 PHP 脚本构建另一个网站。但是,当用户提交表单时,他们不会收到成功消息,而是收到“内部服务器错误”消息。PHP 脚本是相同的(验证码除外)。HTML 是相同的(验证码键除外)和一些 css 样式。下面是 HTML:    <form action="scripts/contact.php" method="post" target="resultMsg" style="width:300px; margin:auto;">        <input class="formInput" type="text" name="name" id="name" placeholder="Name"/>        <br/><br/>        <input class="formInput" type="text" name="email" id="email" placeholder="Email"/>        <br/><br/>        <textarea class="formInput" name="message" id="message" placeholder="Message"></textarea>        <br/><br/>        <div style="margin:auto;width:fit-content">            <div class="g-recaptcha" data-sitekey="xxxxxxxxxxxxxxxx"></div>        </div>        <br/><br/>        <input class="send" type="submit" value="Send"/>    </form>    <br /><iframe name="resultMsg" id="resultMsg" scrolling="no" style="border:0; height:30px; width:100%"></iframe>下面是 scripts/contact.php 文件中的 PHP 代码:<?phpif(isset($_POST['g-recaptcha-response'])){    $captcha=$_POST['g-recaptcha-response'];}if(!$captcha){    echo("<p style='color:white; width:100%; text-align:center;'>Error: Please check the captcha box.</p>");    exit;}$secretKey = "xxxxxxxxxxxxxxxxxxxxxxxx";$ip = $_SERVER['REMOTE_ADDR'];$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secretKey) .  '&response=' . urlencode($captcha);$response = file_get_contents($url);$responseKeys = json_decode($response,true);if($responseKeys["success"]) {    $myemail  = "myemail@ymail.com";    $subject = "Contact Form Submission";    $name = $_POST['name'];    $email = $_POST['email'];    $message = $_POST['message'];上周我遇到了这个问题,但托管公司将其添加AddHandler application/x-httpd-ea-php56 .php到 htaccess 文件中并修复了它。出于某种原因,他们还在整个网站目录中添加了带有这一行的额外 htaccess 文件。然后我想我可能不小心删除或更改了一些 htaccess 文件,现在它不能再工作了。究竟需要在哪个 htaccess 文件中才能正常工作?任何想法为什么它不再起作用?谢谢
查看完整描述

1 回答

?
撒科打诨

TA贡献1934条经验 获得超2个赞

事实证明,问题很简单,就像 PHP 脚本的文件权限不正确一样。将脚本的权限更改为 644 修复了问题,不再出现“内部服务器错误”。


查看完整回答
反对 回复 2021-11-19
  • 1 回答
  • 0 关注
  • 537 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信